$(".hover").hover(function(){
$(this).css("background","#008000");
},function(){
$(this).css("background","#fff");
});
$(".bind").click(function(){
alert("bind");
$('.hover').bind("hover");
});
$(".unbind").click(function(){
console.log("unbind succ===");
$('.hover').unbind('mouseenter').unbind('mouseleave');
});
重新绑定,并没有成功,也就是 $('.hover').bind("hover");这个话没有执行。那有什么方法重新绑定hover事件吗?
谢邀.
事件绑定起码得有俩参数,分别是事件名和处理function。建议再去看看教程或者文档;
这个API有点老了(没记错的话jQ3已经彻底甩掉
.bind()
了,.toggle()
在1.9就已经淘汰了),建议用新版API,.on()
、.off()
等;修改(不知道绑的hover是干嘛用的,权且移花接木):
参考:jQuery:绑定事件处理器
.on()
以上.