js基本事件
js基本事件:
|
属性 |
当以下情况发生时,出现此事件 |
FF |
N |
IE |
|
onabort |
图像加载被中断 |
1 |
3 |
4 |
|
onblur |
元素失去焦点 |
1 |
2 |
3 |
|
onchange |
用户改变域的内容 |
1 |
2 |
3 |
|
onclick |
鼠标点击某个对象 |
1 |
2 |
3 |
|
ondblclick |
鼠标双击某个对象 |
1 |
4 |
4 |
|
onerror |
当加载文档或图像时发生某个错误 |
1 |
3 |
4 |
|
onfocus |
元素获得焦点 |
1 |
2 |
3 |
|
onkeydown |
某个键盘的键被按下 |
1 |
4 |
3 |
|
onkeypress |
某个键盘的键被按下或按住 |
1 |
4 |
3 |
|
onkeyup |
某个键盘的键被松开 |
1 |
4 |
3 |
|
onload |
某个页面或图像被完成加载 |
1 |
2 |
3 |
|
onmousedown |
某个鼠标按键被按下 |
1 |
4 |
4 |
|
onmousemove |
鼠标被移动 |
1 |
6 |
3 |
|
onmouseout |
鼠标从某元素移开 |
1 |
4 |
4 |
|
onmouseover |
鼠标被移到某元素之上 |
1 |
2 |
3 |
|
onmouseup |
某个鼠标按键被松开 |
1 |
4 |
4 |
|
onreset |
重置按钮被点击 |
1 |
3 |
4 |
|
onresize |
窗口或框架被调整尺寸 |
1 |
4 |
4 |
|
onselect |
文本被选定 |
1 |
2 |
3 |
|
onsubmit |
提交按钮被点击 |
1 |
2 |
3 |
|
onunload |
用户退出页面 |
1 |
2 |
3 |
例如:
<script src="js/jquery-3.3.1.min.js">
//基本事件
$(function(){
//单击事件
/* $(".child").click(function(){
console.log(0)
})*/
/* $(".child").mousemove(function(e){
console.log(e.offsetX,e.offsetY);
})*/
/* $(".child").mousemove(function(){
$(this).css("background-color","red");
}).mousemove(function(){
$(this).css("background-color","pink");
})*/
/* $(".child").hover(function(){
$(this).css("background-color","red");
}).mousemove(function(){
$(this).css("background-color","pink");
})*/
function stopPropagation(e){
e.stopPropagation();//阻止事件冒泡
e.preventDefault();//阻止默认行为 reset submit a[href]
return false;
}
//事件模块
$(".child").click(function(e){
console.log(".child");
return stopPropagation(e);
})
$(".parent").click(function(){
console.log(".parent");
})
})
</script>
<!--
Screen 屏幕 显示器左上角
page 页面 当前页面左上角
client 可视区域 显示页面区域的左上角
offset 元素 元素的左上角
页面没有滚动时,page与client基准点重合
-->

浙公网安备 33010602011771号