jQuery绑定事件

//bind 为每个匹配节点绑定事件处理函数,绑定多个用{}。
$("p").bind("click", function(){
alert( $(this).text() );
});
$('#div1').bind({
"mouseover":function () {
$('#div1').parent().removeClass("hide");
},"mouseout":function () {
$('#div1').parent().addClass("hide");
}
});

$("p").one( "click", function(){}) //事件绑定后只会执行一次
$("p").unbind( "click" ) //反绑一个事件

//与bind 不同的是当时间发生时才去临时绑定。
$("p").delegate("click",function(){
您的代码
});

$("p").undelegate();    //p节点删除由 delegate() 方法添加的所有事件
$("p").undelegate("click") //从p节点删除由 delegate() 方法添加的所有click事件

$("p").click();   //单击事件
$("p").dblclick(); //双击事件
$("input[type=text]").focus() //节点获得焦点时,触发 focus 事件
$("input[type=text]").blur() //节点失去焦点时,触发 blur事件
$("button").mousedown()//当按下鼠标时触发事件
$("button").mouseup() //节点上放松鼠标按钮时触发事件
$("p").mousemove() //当鼠标指针在指定的节点中移动时触发事件
$("p").mouseover() //当鼠标指针位于节点上方时触发事件
$("p").mouseout()  //当鼠标指针从节点上移开时触发事件
$(window).keydown() //当键盘或按钮被按下时触发事件
$(window).keypress() //当键盘或按钮被按下时触发事件,每输入一个字符都触发一次
$("input").keyup() //当按钮被松开时触发事件
$(window).scroll() //当用户滚动时触发事件
$(window).resize() //当调整浏览器窗口的大小时触发事件
$("input[type='text']").change() //当节点的值发生改变时触发事件
$("input").select() //当input 节点中的文本被选择时触发事件
$("form").submit() //当提交表单时触发事件
$(window).unload() //用户离开页面时

posted @ 2020-11-21 21:04  陈小伙子  阅读(116)  评论(0编辑  收藏  举报