jquery事件对象

$(document).click(function (ev) { //jq已经兼容好了,就通过事件处理函数的参数传入
    console.log(ev); //jq事件对象
    console.log(ev.originalEvent);//原生对象
    console.log(ev.pageX, ev.pageY); // 鼠标相对于文档的距离
    console.log(ev.clientX, ev.clientY); // 鼠标相对于屏幕可视区的距离
    console.log(ev.offsetX, ev.offsetY); // 鼠标相对于触发事件的元素的左上角的距离
    console.log(ev.screenX, ev.screenY); // 鼠标相对于屏幕的距离
    console.log(ev.which); // 相当于keyCode,比keyCode强大,还可以记录鼠标的键值,123(左中右);

     console.log(ev.target); // 事件源
     console.log(ev.delegateTarget); // 事件绑定的对象
     console.log(ev.type); // 事件类型
     console.log(ev.ctrlKey); // 相应的功能键是否按下
     console.log(ev.shiftKey);
     console.log(ev.altKey)
	
})

阻止冒泡:

    ev.stopPropagation()
    ev.cancelBubble = true

阻止事件默认行为:

 	   return false
       ev.preventDefault();
       ev.returnValue = false

阻止默认事件 + 阻止冒泡的操作

 ev.preventDefault(); // 阻止默认事件
 ev.stopPropagation(); // 阻止冒泡的操作
  
 return false; // 阻止默认事件 + 阻止冒泡的操作
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值