jQuery selectors' functions select a matching element from HTML DOM.

In simple words, jQuery selectors are used to select HTML elements, and after selecting the elements, you can perform various operations on them.

  • JQuery selectors always start with a dollar sign called the factory function $().
  • jQuery Selector is a function used to select and manipulate HTML DOM elements.
  • jQuery Selectors works with HTML DOM elements like name, id, classes, types, attributes, values of attributes, and many more.

Mainly Used jQuery Selectors

Selector Type Example Description
$("p") Element Selector
Hides all HTML <p> tags.
$(".article") Class Selector
Hides all elements with class="article".
$("#menu") ID Selector
Hides the element with id="menu".

jQuery Selector Example

<!DOCTYPE html>
<title>jQuery with HTML Example</title> 
<script src = "//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>


<p>This is sample text.</p>


In the above example, the body color of the web page will become pink when the document is ready.