jqeury bind 绑定事件与 unbind删除绑定事件

<1>

<html><head><title></title><script src="../jquery-2.1.3.js"></script></head><body><button id="a">a</button><button id="b">b</button><button id="c">c</button></body></html><script type="text/javascript">//绑定一个事件$("#a").bind("click", function () {alert("单击事件");})//同时绑定多个事件,每个事件执行不同的任务$("#b").bind({"mouseover": function () {alert("鼠标进入");},"mouseout": function () {alert("鼠标移出");}});//同时绑定多个事件,,多个事件都执行一个任务$("#c").bind("click mouseover", function () {alert("弹窗!");})$("button").bind("dblclick", f1);function f1() {alert("我是f1");}$("button").unbind();//删除button控件的全部事件。这样上面button按钮绑定的事件就全被被删除掉了,所以的事件就不起作用了。$("button").unbind("click"); //删除button控件绑定的click事件。 这样绑定在button控件上的click事件就不起作用了$("button").unbind("click mouseover"); //删除button控件绑定的click,和mouseover事件$("button").unbind("click", f1); //删除button控件上绑定f1函数的click事件 (即:假如我button控件绑定了click事件,如果这个事件的处理函数是f1,那么就删除这个click事件)</script>

把自己当傻瓜,不懂就问,你会学的更多

jqeury bind 绑定事件与 unbind删除绑定事件

相关文章:

你感兴趣的文章:

标签云: