//.click()绑定单击事件,回调函数中的参数是当前的jQuery事件
$('.i1').click(function(e) {
alert('w shi ni baba!');
console.log(e);
})
//.click()无参时,相当于调用函数,用于触发指定的事件。
$('.i2').click(function() {
$('.i1').click();
})
//.click()还可以接受一个参数作为jQuery事件对象的data属性值,而this指向的是当前的DOM对象。
$('.i3').click('yeye',function(e) {
console.log(this);
console.log(e.data);
})
//.dblclick()函数同click一样,只是触发条件是点击松开再点击。
//.mousedown() and .mouseup()监听鼠标的点下和松开。
//.mousemove()监听鼠标移动。
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() 监听input和textarea
//.submit() 表单提交
//.keyup()松开时触发 .keydown()按下时触发
//.keypress()按下时触发,主要用来捕获单个字符。
//.on()多事件绑定 .hover()不行
$('div.i4').on('mouseenter mouseleave dblclick',function() {
$(this).toggleClass('red');
}) ;
//.on({
// mouseover:function() {},
// mouseout: function() {}
// })
//以及可以增加一个参数放在第二个位置用作传递数据。
//.on()的事件委托方法
//.on(event,[selector],func)将事件的触发委托给设定的选择器
//.off()卸载事件
//jQuery对象的属性和方法
//event.type事件类型
//event.pageX 和 event.pageY 鼠标相对与页面的位置
//event.preventDefault() 阻止默认行为
//event.stopPropagation() 阻止冒泡
//event.which 获取单机的鼠标键
//event.target目标事件DOM
//this 当前冒泡DOM元素
//event.currentTarget 等同于this
//.trigger() 自定义触发on事件。
//.triggerHandler() 不影响原生事件,不冒泡。
//jQuery的动画效果方法。
//.hide() 隐藏元素,可以设置一个参数作为动画执行的时间。设置第二个参数作为回调函数在动画完成后执行。
//.show()
//.toggle()
//.slideDown()
//.slideUp()
//.slideToggle()
//.fadeOut()
//.fadeIn()
//.fadeToggle()
//.fadeTo(duration,opacity,callback)
//$.trim()
//.index()