$(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; // 阻止默认事件 + 阻止冒泡的操作
1687

被折叠的 条评论
为什么被折叠?



