开发者

Force hover on HTML element

I need to decieve an HTML element into thinking my cursor id hovering over it.

Can anyone tell me how I might accomplish this? I know I can to something like thi开发者_运维知识库s $(this).click() to simulate a mouse click. I need an equivalent for hovering.

Thanks


You can use $(el).trigger('mouseover') but that will only execute any hover callbacks you've set up. It won't trigger the browser's hover detection such as for applying css hover rules.

jsFiddle

$(function() {
    $('#s').hover(function() { alert('Wee'); });

    $('#b').click(function() { $('#s').trigger('mouseover'); });
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜