0 points

Select Elements with Class Attribute using jQuery


Posted by @mishka #javascript

Step 0: Add class to the HTML element(s) you wish to select

<h2 class="redHeading">Welcome</h2>
<p>A passage of text</p>
<h2 class="redHeading">Thank you</h2>
content_copy Copy

Step 1: Add script to HTML file or js file

	var redHeaders = $(".redHeading"); 
content_copy Copy

Make sure jQuery has been already added to project. Can be applied to one or multiple element(s).