Introduction
We use selectors for finding elements from the DOM and we will manipulation that element. There are various types of selectors. Each selector starts with dollar ($) symbol and round brackets.
Types of jQuery Selectors
There are 3 types of selectors:
- Element selector
- Id selector
- Class selector
Element selector
It will select an element using the element name.
Example:
- $("div").hide();
Id selector
In scripting language, we use '#' as the symbol of id. We can use once a particular name as id in a single page.
Example:
- $("#divUnused").hide();
Class selector
In scripting language, we use '.' as the symbol of class. We can use a name as many times in a single page.
- $(".divUnused").hide();
jQuery Selectors Code Examples
- $("*").hide();
- $(".p").click(function(){
- $(this).hide();
- });
- $("p.intro").hide();
- $("p:first").hide();
- $("ul li:first").hide();
- $("ul li:first-child").hide();
- $("[href]").hide();
- $("a[target='_blank']").hide();
- $("a[target!='_blank']").hide();
- $(":button").hide();
- $("tr:even").hide();
- $("tr:odd").hide();
Summary
In this blog and code examples, I discussed types of jQuery selectors and how to use them in our application. I hope this blog helps you understand jQuery selectors.

Join the conversation! Your thoughts help the community grow.