In jQuery, we can select elements with multiple classes using the .class
selector.
All the classes that are to be selected are specified as below.
$('.class1.class2.class3...')
In the HTML tab:
id=content
.p
elements with class=line
.Note: We added the
show
class to the third and fifthp
element.
Highlight
.jQuery
script.In the JavaScript tab:
click()
method on the Highlight
button..class
selector to select all the elements with classes line
and show
. Also, we use the toggleClass()
method to toggle class highlight
.Highlight
button is clicked, all the elements with classes line
and show
are selected.