JQuery Selectors

jQuery Selectors syntax and example for jquery selectors
JQuery is selectors are being important one using this only we can apply the changes. Selectors are used to select the html element in the web page. Html element must in the form of tags, class, id, attributes and more. You see the selectors below.

Syntax:
$(document).readyfunction(){
$(selectors).action();
});

Element Selector
This element selector is used to select elements based on the element name. If used the element by name it must be enclosed with the quotes. Like this $("div").

Example:
$(document).ready(function(){
$("div").click(function(){
$("img").fadeIn();
});
});

.class Selector
Class Selector is used to select the particular element by the class name. The class should occur any number time in the webpage. Class Selector should be like this $("red_btn").

Example:
$(document).ready(function(){
$(".red_btn").click(function(){
$("img").fadeIn();
});
});

ID Selector
ID Selector is used to select the particular element by the id name. ID should be occurred unique in the web page. Use single time on the web page. It would be like this $ ("#green_btn")

Example:
$(document).ready(function(){
$("#green_btn").click(function(){
$("img").fadeIn();
});
});
Copyright Labw3