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'); });
});
精彩评论