Phillip Senn
Phillip Senn

Reputation: 47595

Finding every occurrence of a class and removing that class

This will find everything within id="myID" that has class="myClass" and remove class="myClass":

$('#myID').find('.myClass').removeClass('myClass')

Q: Is there a shorter way of accomplishing the same thing? I just want to double check my syntax to make sure that I'm doing it the best way.

Upvotes: 0

Views: 33

Answers (1)

AmmarCSE
AmmarCSE

Reputation: 30557

You can search descendants in the selector and not use find()

$('#myID .myClass').removeClass('myClass')

Upvotes: 2

Related Questions