jQuery解除繫結事件
阿新 • • 發佈:2018-11-06
off方法:不帶引數,解綁元素上所有的方法
帶一個引數,解綁這型別的方法
帶二個引數,解綁這型別指定的方法
<html> <head> <title></title> </head> <style> </style> <script src="http://code.jquery.com/jquery-latest.js"></script> <script> $(function(){ function test(){ alert("wjw") } function test1(){ alert("wjw") } $('button').click('test') $('button').click('test1') $('button').mouseout(function(){ alert("wjw") }) //$('button').off(); //解除button上的所有繫結事件 //$('button').off('click') //解除button上的所有click事件 $('button').off('click',test) }) </script> <body> <button>按鈕</button> </body> </html>