jQuery: Wildcard class selector in removeClass

后端 未结 4 1103
情书的邮戳
情书的邮戳 2020-12-21 09:46

This code snippet works to remove an existing class, before adding a new one, when I specify it directly (ie, \'ratingBlock\', \'ratingBlock1\', \'ratingBlock2\', etc.). But

4条回答
  •  -上瘾入骨i
    2020-12-21 10:19

    $.removeClass() doesn't take a selector as a parameter, only a class name (or class names).

    See: Removing multiple classes (jQuery)

    So you basiacally need to call:

    $.removeClass('ratingBlock1 ratingBlock2 ratingBlock3 ratingBlock4 ratingBlock5');
    

提交回复
热议问题