Jump to content

How to target an element by its class in jQuery


KenBrace

Recommended Posts

One of the best things about jQuery is its powerful and easy-to-use selector system.

 

So how do you select an item in HTML by its class name?

 

Let's say I have an element with a class of "blue". I could select this element in jQuery using the following code.

 

 

$(".blue");

 

Simple as that. Note that all we had to do was place a period before the name of the class. This period tells jQuery that you are attempting to select a class.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...