$( function (){ |
$( "div" ).bind( "click" , function (){ |
$( "body" ).append( "<p>click事件</p>" ); |
}); |
$( "div" ).bind( "mouseover.plugin" , function (){ |
$( "body" ).append( "<p>mouseover事件</p>" ); |
}); |
$( "div" ).bind( "dblclick.plugin" , function (){ |
$( "body" ).append( "<p>dblclick事件</p>" ); |
}); |
$( "button" ).click( function () { |
$( "div" ).unbind( ".plugin" ); //移除后click事件仍然有效 |
}) |
}) |
|
<div style= "width:100px;height:50px;background:#888;color:white;" >test.</div> |
<button >根据命名空间,删除事件</button> |