jQuery determine if ul has class OR another one

前端 未结 7 2270
野趣味
野趣味 2020-12-09 07:56

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(\'curren         


        
7条回答
  •  没有蜡笔的小新
    2020-12-09 08:21

    The following is what you've in mind:

    var menuItem49 = $('#menu-item-49');
    if (menuItem49.hasClass('current-menu-item') || menuItem49.hasClass('current-menu-parent')) {
        // ...
    }
    

提交回复
热议问题