Reputation: 14145
On html page I have multiple elements like,
<a class="myInput red selected" selectable="">1</a>
<a class="myInput blue selected" selectable="">2</a>
point is that I could have many different myInput classes like red, blue, green, ...
Now I want on certain event to remove all selected
classes from entire document.
I know that I should use .removeClass("selected")
but I dont know how to apply on whole document to many elements
Upvotes: 0
Views: 58
Reputation: 826
You can check with the code.
$(selector).removeAttr(attribute)
you can refer the below link too.
Upvotes: 1
Reputation: 74738
You can do this:
$('.myInput.selected').removeClass('selected');
it only removes the selected
css class from the myinputs
and which has the class selected
.
Upvotes: 3
Reputation: 5123
You can use each loop like this as well :-
$('.selected').each(function(){
$(this).removeClass("selected");
});
Upvotes: 1
Reputation: 337560
You can find all .selected
elements and remove the class like this:
$('.selected').removeClass('selected');
If there are multiple .selected
elements found in the document jQuery will internally loop over all of them for you and change the class.
Upvotes: 6