开发者

Force hover on HTML element

开发者 https://www.devze.com 2023-03-12 07:28 出处:网络
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

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

精彩评论

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