Jquery Selectors

jQuery selectors are used to find or select HTML elements based on their class, id, value, type or attribute.

jQuery offers a powerful set of tools for matching a set of elements in a document.

Jquery selectors are start with the: $().

[code language=”html” line=”1″ highlight=”3″]
<p>All Selector (“*”)</p>
<p><li>Selects all elements.</p>

Demo – All Selector

<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>all demo</title>
h3 {
margin: 0;
div, span, p {
width: 80px;
height: 40px;
float: left;
padding: 10px;
margin: 10px;
background-color: #EEEEEE;
#test {
width: auto;
height: auto;
background-color: transparent;
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<div id="test">
<p>P <button>Button</button></p>
$( document ).ready(function() {
var elementCount = $( "#test" ).find( "*" ).css( "border", "3px solid red" ).length;
$( "body" ).prepend( "<h3>" + elementCount + " elements found</h3>" );

[code language=”html” line=”1″]
<li>hide() method hidies all the elements with id="demo".</li>
<li>hide() method hides all he elements with class="demo".</li>
<li>hide() method hides the current HTML element.</li>