首页 > 其他 > 详细

delegate事件绑定

时间:2016-08-20 12:53:52      阅读:192      评论:0      收藏:0      [点我收藏+]

为了代码的健壮性,绑定事件之前先解绑再进行绑定。

var _$div = $("#id");
_$div.undelegate("click mouseover mouseout dblclick");//先解绑所有的事件
_$div.delegate(".sonDiv","mouseover mouseout dblclick",function(e){
  var _type = e.type;
if(_type == "mouseover"){
    
}else if(_type == "mouseout"){

}else if(_type == "dblclick"){

}
});
_$div.delegate(".finished","click",_case,function(e){
alert(e.data);
});

delegate事件绑定

原文:http://www.cnblogs.com/huahua-1022/p/5790107.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!