Javascript 将jQuery悬停添加到函数
考虑到我有以下函数表示法:Javascript 将jQuery悬停添加到函数,javascript,jquery,Javascript,Jquery,考虑到我有以下函数表示法: $('a').bind('click hover', function(e) 如何为悬停添加操作,类似于: $("a").hover(function() { //hover in stuff here }, function() { //hover out stuff here }); 悬停实际上并不存在,它只是mouseenter/mouseleave的快捷方式。就用这个: $('a').bind(
$('a').bind('click hover', function(e)
如何为悬停添加操作,类似于:
$("a").hover(function() { //hover in stuff here
}, function() {
//hover out stuff here
});
悬停实际上并不存在,它只是mouseenter/mouseleave的快捷方式。就用这个:
$('a').bind('click mouseenter mouseleave', function(e){});
此外,在较新版本的jQuery中,应该使用.on而不是.bind
还请注意:
$("a").hover(function() { //hover in stuff here
}, function() {
//hover out stuff here
});
与此不同:
$('a').bind('mouseenter mouseleave', function(e){});
但和
$('a').bind({
mouseenter : function(e){},
mouseleave : function(e){}
});
请使用mouseover和mouseout事件进行相同的操作。同意@JayeshGoyani使用mouseenter/mouseover进行一次操作,mouseout进行相反的操作。