$('p').on('click',function(){ //code here ... });
$(document父).on('click','p子',function(){ //code here... })
$(document).ready(function(){ $("p").on({ mouseover:function(){$(this).css("background-color","lightgray");}, mouseout:function(){$(this).css("background-color","lightblue");}, click:function(){$(this).css("background-color","yellow");} }); });
$( "p" ).off();
$( "p" ).off( "click", "**" );
$( "body" ).off( "click", "p", foo );
$(document).off(".someclass");
$( "#foo" ).one( "click", function() { alert( "This will be displayed only once." ); });
$("#foo").on("click", function(event){ alert("This will be displayed only once."); $(this).off(event); });
版权声明:本文为博主原创文章,未经博主允许不得转载。
原文地址:http://blog.csdn.net/wujiangwei567/article/details/47081523