jQuery Selectors

Posted on

hfghfhjQuery Selectors

jQuery helps to select the html tags and we can perform any kind of function on them and Can control them.

jQuery selectors are used to “find” (or select) HTML elements with help of  their id, class,tag name and much more.selectors start with the dollar sign in jquery: $().

 The element Selector

The jQuery selector selects html elements of tags with the help of the tag  name.

To select all p tag we use like this:

$(“p”)

Example

When a user clicks on a button, all <p> elements will be hidden:

Example

$(document).ready(function(){
$(“button”).click(function(){
$(“p”).hide();
});
});

 The #id Selector

The jQuery #id selector uses the id attribute of an HTML tag to find the specific element.

We have to give a unique id to tags with in a page, we will use #id selector when you want to find a single, unique element.

Id is start with # sign and written in (“”) double codes.

 $(“#test”)

Example

When a user clicks on a button, the element with id=”test” will be hidden:

Example

$(document).ready(function(){
$(“button”).click(function(){
$(“#test”).hide();
});
});

 The .class Selector

The jQuery class selector use to select the html element with the help of class selector.(.) dot operator is use to define the class in the jquery.it is use for multiple selection of same class name element like in shpping site product have same class and the value of every product different. :

$(“.test”)

Example

When a user clicks on a button, the elements with class=”test” will be hidden:

Example

$(document).ready(function(){
$(“button”).click(function(){
$(“.test”).hide();
});
});

For more details and queries please feel free to email, visit or call us. Wishing you the very best for all your future endeavors.

Helpline: 9814666333, 8699444666

Email:info@technocampus.co.in

**************************************************************************************************************

Please fill the FORM and we shall contact you soon.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s