0 works

Select Elements with Class Attribute using jQuery


dashboard

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_copyCopy to Clipboard

Step 1: Add script to HTML file or js file

<script>
	var redHeaders = $(".redHeading"); 
</script>
content_copyCopy to Clipboard

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


>> Browse more code snippets

more_vert