Javascript 如何在鼠标悬停div上编写此函数?
如何编写此函数,以便当鼠标停留在div.rest上时触发调用。代码如下:Javascript 如何在鼠标悬停div上编写此函数?,javascript,Javascript,如何编写此函数,以便当鼠标停留在div.rest上时触发调用。代码如下: $(document).bind('mousemove', function() { resetActive() }); 当鼠标停留在所需的div.resting上时,我希望它调用resetActive。如何编写代码 $(".resting").mouseover(function() { resetActive(); }); 或者,为了干净和更好的实践 $('.resting').on('mouse
$(document).bind('mousemove', function() {
resetActive()
});
当鼠标停留在所需的div.resting上时,我希望它调用resetActive。如何编写代码
$(".resting").mouseover(function() {
resetActive();
});
或者,为了干净和更好的实践
$('.resting').on('mouseenter', resetActive);
// and later
$('.resting').off('mouseenter', resetActive);
要获得该活动:
var resetActive = function(e) {
// do something...
}
或者,为了干净和更好的实践
$('.resting').on('mouseenter', resetActive);
// and later
$('.resting').off('mouseenter', resetActive);
要获得该活动:
var resetActive = function(e) {
// do something...
}
$(“div.rest”).mouseover(function(){})?$(“div.rest”).mouseover(function(){})?为什么
bind()
/unbind()
而不是on()
/off()
?请注意,jQuery团队鼓励.on/.off,而不是.bind/.unbind或.eventname为什么bind()
/unbind()
而不是on()
/off()
?请注意,jQuery团队鼓励使用.on/.off,而不是.bind/.unbind或.eventnameAn,因为OP提供了他们正在使用的类,所以不需要使用ID,因为OP提供了他们正在使用的类。