jQuery selectors gives you the facility to select and manipulate HTML elements according to your needs and requirements.
The element Selector
Based on the element name,The jQuery selector element selects elements.
Example
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("p").hide();
});
});
</script>
</head>
<body>
<h2>This is Evon Technologies</h2>
<p>This is a paragraph.</p>
<p>This is Logic simplified.</p>
<button>Click</button>
</body>
</html>
The #id Selector
For finding the specific element,the id attribute of an HTML element is used.
An id should be unique in a page
Example
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("#t").hide();
});
});
</script>
</head>
<body>
<h2>This is Dehradun</h2>
<p>This is a meerut.</p>
<p id="t">Haldwani.</p>
<button>Click </button>
</body>
</html>
0 Comment(s)