Вопрос

I use mouseenter on a class but if that class has another class the mouseenter method should not be triggered. I tired the below code but for some reason I do not get it is not working. Any ideas why and maybe some suggestions?

$(".someClass:not('.someOtherClass')").mouseenter(function(){ 
    //some code
});
Это было полезно?

Решение

This piece of code triggers on enter of someClass If the mouse does not have a class of someOtherClass it will execute the //do this code.

 $(".someClass").mouseenter(function(e){ 
     if (!$(e.target).hasClass('someOtherClass')){
         // do this
     }
 });
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top