JQUERY SELECTOR
Jquery selector are use for selecting element in web html page. element are the tags present in html page.
as you know you want to find your friends house you must have to know his address .
same you must know the address of your element to find it in html document.
In real time address is defined by house no. To find the house with house no. house is assigned a number and name plate and number plate should written on it same in Jquery and html element should have a selector defined on it
Types Of Selector
1 By tag
2 By class
3 By id
By Tag
Selection by Tag is simplest one but it select all tag present in the html page
syntax
$("a")
This select all a tag present in page
By class
Tag selection by class is the way to select some element from the html page but when you select element by class each and every tag having class name which you are selecting is got selected.
"." , read as dot is use to select classes
syntax
<a class="FirstClass" href="www.google.com" >This is Simple Link </a>
$(".FirstClass")
In This Example ancor tag present with class "FirstClass" and the other is use To select that element
By ID
Tag selection By id use to select single element in Html Document
in any html element no two element can have same id
every element must have different ids
"#" read as Hash is use to select element with id
<a class="FirstClass" id="FirstId" href="www.google.com" >This is Simple Link </a>
$("#FirstId")In This Example ancor tag present with id " FirstId" and the other is use To select that element having id "FirstId"
Note
1 No two element have same id in html page.
2 Id and class can have any name user want , it is not predefined but it is a valid Identifier.
3 This syntax only work when Jquery script is attached to that page .
Comments
Post a Comment