jQuery基础:下(事件及动画效果)
生活随笔
收集整理的這篇文章主要介紹了
jQuery基础:下(事件及动画效果)
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
//.click()綁定單擊事件,回調(diào)函數(shù)中的參數(shù)是當(dāng)前的jQuery事件$('.i1').click(function(e) {alert('w shi ni baba!');console.log(e);})//.click()無參時,相當(dāng)于調(diào)用函數(shù),用于觸發(fā)指定的事件。$('.i2').click(function() {$('.i1').click();})//.click()還可以接受一個參數(shù)作為jQuery事件對象的data屬性值,而this指向的是當(dāng)前的DOM對象。$('.i3').click('yeye',function(e) {console.log(this);console.log(e.data);})//.dblclick()函數(shù)同click一樣,只是觸發(fā)條件是點(diǎn)擊松開再點(diǎn)擊。//.mousedown() and .mouseup()監(jiān)聽鼠標(biāo)的點(diǎn)下和松開。//.mousemove()監(jiān)聽鼠標(biāo)移動。function data(e) {$(this).find('button:last').html(e.data);}function a() {$('body').mousemove(5,data);}a();//.mouseover() and .mouseout()冒泡//.mouseenter() and .mouseleave()阻止了冒泡//.hover()$('button:last').hover(function(){$(this).css('background','red');},function() {$(this).css('background',"");})//.focusin() and .focusout()阻止了冒泡//.focus() and .blur()冒泡//.change() 表單事件//.select() 監(jiān)聽input和textarea//.submit() 表單提交//.keyup()松開時觸發(fā) .keydown()按下時觸發(fā)//.keypress()按下時觸發(fā),主要用來捕獲單個字符。//.on()多事件綁定 .hover()不行$('div.i4').on('mouseenter mouseleave dblclick',function() {$(this).toggleClass('red');}) ;//.on({// mouseover:function() {},// mouseout: function() {}// })//以及可以增加一個參數(shù)放在第二個位置用作傳遞數(shù)據(jù)。//.on()的事件委托方法//.on(event,[selector],func)將事件的觸發(fā)委托給設(shè)定的選擇器//.off()卸載事件//jQuery對象的屬性和方法//event.type事件類型//event.pageX 和 event.pageY 鼠標(biāo)相對與頁面的位置//event.preventDefault() 阻止默認(rèn)行為//event.stopPropagation() 阻止冒泡//event.which 獲取單機(jī)的鼠標(biāo)鍵//event.target目標(biāo)事件DOM//this 當(dāng)前冒泡DOM元素//event.currentTarget 等同于this//.trigger() 自定義觸發(fā)on事件。//.triggerHandler() 不影響原生事件,不冒泡。//jQuery的動畫效果方法。//.hide() 隱藏元素,可以設(shè)置一個參數(shù)作為動畫執(zhí)行的時間。設(shè)置第二個參數(shù)作為回調(diào)函數(shù)在動畫完成后執(zhí)行。//.show()//.toggle()//.slideDown()//.slideUp()//.slideToggle()//.fadeOut()//.fadeIn()//.fadeToggle()//.fadeTo(duration,opacity,callback)//$.trim()//.index()
?
轉(zhuǎn)載于:https://www.cnblogs.com/FunkyEric/p/9182686.html
總結(jié)
以上是生活随笔為你收集整理的jQuery基础:下(事件及动画效果)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 第二十天
- 下一篇: Oracle 分组统计,抽取每组前十