Alex Rivera | Logout

jQuery determine if ul has class OR another one

Asked 2010-07-07T16:03:19.830
36

what is the right way to determine if an object has one class OR another one? The following is appearantly wrong..

if ($('#menu-item-49').hasClass('current-menu-item' || 'current-menu-parent') ) {
  $('ul.sub-menu ').css('display', 'block');
}

Thanks!

Edit
Report

1 Answer

0

Do it like this instead, separating it in two bits:

if ($('#menu-item-49').hasClass('current-menu-item') || $('#menu-item-49').hasClass('current-menu-parent') ){
   $('ul.sub-menu ').css('display', 'block');
}

Hope this helps you

answered 2010-07-07T16:07:09.090

Your Answer