how to use Jquery selector....?
JQuery selectors are used to find HTML elements based on
their id, classes, types, attributes, values of attributes and much
more.
All selectors in jQuery start with the dollar sign: $().
There are different type of selector use in jquery.
Element selector.
ID selector.
Class Selector.
1. Element selector.
The jQuery element selector selects elements based on the element name.
You can select all <div> elements on a page like this:
$("element-name")
<head>
$(document).ready(function(){
$("element-name").css("background","red");
});
});
</head>
2. Id selector
The jQuery #id selector uses the id attribute of an HTML tag.
you should use the #id selector when you want to find a single, unique element.
To find an element with a specific id, write a hash character.
$("#id-name")
<head>
$(document).ready(function(){
$("#id-name").css("background","red");
});
});
</head>
3. Class selector
The jQuery class selector finds elements with a specific class on write a dot(.) character.
$(".class-name")
<head>
$(document).ready(function(){
$(".class-name").css("background","red");
});
});
</head>
No comments
Post a Comment