replacement for hover() in jquery1.9?

2019-09-21 02:05发布

How do I use mouseneter mouseleave instead of hover(). Should i use them both instead of hover()?

$('#somegrid').hover(
function () {
    //something;
},

What about legacy code - I mean what goes in mouseenter , what goes in mouseleave? i just had one action on hover()

2条回答
欢心
2楼-- · 2019-09-21 02:18

look at the api for hover

the hover function is shorhand for:

$( selector ).mouseenter( handlerIn ).mouseleave( handlerOut );

or if you are only passing in one handler:

$( selector ).on( "mouseenter mouseleave", handlerInOut );

the examples in the api illustrate this well.

查看更多
我想做一个坏孩纸
3楼-- · 2019-09-21 02:22

Like this -

$('#somegrid').on('mouseenter',function(){
 // mouseenter
}).on('mouseleave',function(){
 //  mouseleave
});
查看更多
登录 后发表回答