javascript - Unable to check if element hasClass, then not animate the element -


explanation in context(wordpress): want check if li element has class called "current-menu-item" if want stop animate function. if not have class continue animating. script not working. help.

$(document).ready(function () {     $('.nav li a').hover(function()      {         if ($(this).parentnode.hasclass('current-menu-item'))         {         alert('this item has class of current-menu-item');         }         else         {         $(this).animate({color:'#3b3b3b'}, 300, 'linear');         }     },      function()          {         if ($(this).parentnode.hasclass('current-menu-item'))         {         // nothing         }         else          {             $(this).animate({color:'#999'}, 300, 'linear');         }     }); }); 

if ($(this).parent().hasclass('current-menu-item')) 

jquery objects don't have parentnode property. dom elements do, element returned parentnode doesn't have jquery methods .hasclass(). use jquery's .parent() method instead.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -