jQuery Selectors: An jQuery for Beginners

What is Selectors?

The document we have written in blue text with $ is called selectors.

And what is in the right side of the document, we call it method

Our selector part is written to target the dang of HTML or to select the dang element.
And after selecting you do the work you want to do in the method.

In this blog, the part which you select is learned in detail.

Which is our selector part, it basically consists of CSS selectors,

These were our basic selectors

And which are basic selectors like -> Id, Class, Tag Name.
If you want to target an HTML element with id, then you can write for it as if we are showing the image above.

For ID
For Class
For Tag

These were our basic selectors apart from this, there are also advance selectors

Advance selectors

$(“*”) Advance selector gets first star (*) tag

Star means all the tags written inside HTML, if you want to target all of them within a page, or want to do CSS like that if you want to pink their HTML, then you can put star tags.

Example for Id:

Result:

Example for <li> Tag:

Result:

Example for Class Tag:

Result:

Example for (*) Star Tag:

Result:

Rajesh Kumar
Follow me
Latest posts by Rajesh Kumar (see all)