Removing multiple classes (jQuery)

前端 未结 8 1921
醉梦人生
醉梦人生 2020-11-30 16:56

Is there any better way to rewrite this:

$(\'element\').removeClass(\'class1\').removeClass(\'class2\');

I cannot use removeC

相关标签:
8条回答
  • 2020-11-30 17:37

    $('element').removeClass('class1 class2');

    Here are the docs.

    0 讨论(0)
  • 2020-11-30 17:48
    $("element").removeClass("class1 class2");
    

    From removeClass(), the class parameter:

    One or more CSS classes to remove from the elements, these are separated by spaces.

    0 讨论(0)
提交回复
热议问题