jQuery 如何在没有真正鼠标悬停时触发元素上的鼠标悬停功能
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15350603/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to trigger mouseover function on an element when not really mouseovered
提问by ofer dofer
In jQuery, is it possible for an element to act like it is mouseovered automatically when the page is loading, when it is not really mouseovered? I mean, I won't put my pointer on the desired element for it to do what it would do if I put.
在 jQuery 中,当页面加载时元素不是真的鼠标悬停时,它是否可以像鼠标悬停一样自动悬停?我的意思是,我不会将我的指针放在所需的元素上,以便它执行我放置时会执行的操作。
回答by jmoerdyk
回答by Ven
You can call the handler directly
您可以直接调用处理程序
$('abc').mouseover();
回答by Michael Durrant
Put the desired action in the document.ready
function as that is when you actually want the action, not on a mouse-over that doesn't happen.
将所需的操作放在document.ready
函数中,因为这是您真正想要的操作,而不是鼠标悬停在不会发生的情况下。