jQuery check hover status before start trigger

孤者浪人 提交于 2019-11-30 14:59:29

To check whether something is being hovered, you can use the :hover selector, e.g.:

$('#test').click(function() {
    if ($('#hello').is(':hover')) {
        alert('hello');
    }
});

Example here: http://jsfiddle.net/AyAZx/5/

actionshrimp's answer is broken as of jQuery 1.9.1.

Use instead

$("#idOfYourElement:hover").length > 0

in your if condition

http://jsfiddle.net/mathheadinclouds/ZKGqe/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!