Learn how to get element by class using jquery .class selector. Find the HTML elment by class and apply effect, CSS and other useful jQuery methods.

In this tutorial, you will learn how to get element using the class of the element and the jquery selector. You can use the click event to get element by class.

How to Get Element By Class and Find Element with Single Class

Below is the example to perform this task. A click function contains the jQuery css method to apply the CSS to the HTML element when someone click on the text.

The text contains the class .myPara, which can be use to access the HTML element and apply the jQuery methods.

Output

Click Below text.

This is the simple paragraph.

Click on the paragraph given in the simple example above and on click of the paragraph, CSS will add to it.

Get Element By Class and Find Element with Two Class

If you have elements with same class name, you can access the required element using the other class. Suppose there are same classes in three paragraphs and you want to find only the required HTML element. You can use the second class with the HTML element.

Output

Click Below text.

First paragraph to show you the get element method.

Second paragraph to show you the get element method.

Third paragraph to show you the get element method.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.