Jquery condition check is(':hover') not working

后端 未结 8 1374
-上瘾入骨i
-上瘾入骨i 2020-11-28 15:15
$(\'.xx\').mouseenter(function(){
  if($(this).is(\':hover\'))
    alert(\'d\');
  else
     alert(\'f\');
});

Here is my code, it should alert \'d

相关标签:
8条回答
  • 2020-11-28 15:56

    why dont you just use .hover?

    $(".xx").hover(function(){
        alert("d");
    });
    
    0 讨论(0)
  • 2020-11-28 15:59
    function idIsHovered(id){
        return $("#" + id + ":hover").length > 0;
    }
    

    http://jsfiddle.net/mathheadinclouds/V342R/

    0 讨论(0)
提交回复
热议问题