How do I check if the mouse is over an element in jQuery?

前端 未结 24 2463
不思量自难忘°
不思量自难忘° 2020-11-22 08:10

Is there a quick & easy way to do this in jQuery that I\'m missing?

I don\'t want to use the mouseover event because I\'m already using it for something else. I

24条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-22 09:13

    You can use is(':visible'); in jquery And for $('.item:hover') it is working in Jquery also.

    this is a htm code snnipet :

        
  • Matiers
  • and this is the JS Code :

    $('.menutop > li').hover(function() {//,.menutop li ul
    
        $(this).find('ul').show('fast');
    
    },function() {
        if($(this).find('ul').is(':hover'))
        $(this).hide('fast');
    
    });
    
     $('.root + ul').mouseleave(function() {
        if($(this).is(':visible'))
        $(this).hide('fast');
    
    });
    

    this what i was talking about :)

提交回复
热议问题