JQuery.hasClass method to lower the effect

I created a simple background effect for some tabs on the page, but I do not want this effect to work if the tab has the current current.

I guess there is a way to do this using .hasClass

Here is what I use for the effect:

$('ul.htabs a').mouseover(function(){

 $(this).stop().animate(
  {backgroundPosition:"(0 -810px)"}, 
  {duration:150},
  {easing: 'easeOutCubic'})
 }).mouseout(function(){
 $(this).stop().animate(
  {backgroundPosition:"(0 -806px)"}, 
  {duration:150},
  {easing: 'easeInCubic'})
 });
+3
source share
3 answers

You can also put it in a selector:

$('ul.htabs:not(.current) a').mouseover(function(){ ... });
+4
source
.mouseover(function(e) {

if ( $(this).hasClass('lol') ) {
  return;
}

if the item has a class lol, immediately disable the function.

+2
source

:not() :

$('ul.htabs:not(.current) a').mouseover(function(){
    // ... your code here
});

, current ( Matt!) <a>, , mouseover , . current , live(), , - , current:

$('ul.htabs:not(.current) a').live('mouseover', function(){
    // ... your code here
});
0
source

Source: https://habr.com/ru/post/1749252/


All Articles