Question

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
});
Was it helpful?

Solution

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
     }
 });
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top