Target the same element with multiple jQuery Selectors
Now you know three ways of targeting elements: by type:
$("button"), by class:
$(".btn"), and by id
Although it is possible to add multiple classes in a single
.addClass() call, let's add them to the same element in three separate ways.
.addClass(), add only one class at a time to the same element, three different ways:
animated class to all elements with type
shake class to all the buttons with class
btn-primary class to the button with id
You should only be targeting one element and adding only one class at a time. Altogether, your three individual selectors will end up adding the three classes
The content on this page is licensed under Attribution-ShareAlike 4.0 International. Original authors: freeCodeCamp, the content was modified.