Jquery Tag Name Selector
Tag Name Selector select the HTML element by specify tag name
Syntax for Tag Name Selector
$("tag Name")
Example
Tag Name select all tag with same name like an array and you need to give index number
<DOCTYPE html>
<head>
<title> tag name selector </title>
<script src="path of jquery file (which you download from jquery.com)"></script>
<!-- you can also use cdn--->
</head>
<body>
<p> select paragraph by tag name selector </p>
<p> Jquery is javascript library </p>
<script>
$(document).ready(function(){
$("p")[0].style.color="red";
})
</script>
</body>
</html>
Result
select paragraph by tag name selector
jquery is javascript library
Select single heading tag name
Example
<DOCTYPE html>
<head>
<title> select single tag </title>
<script src="path of jquery file"></script>
</head>
<body>
<h1> select heading by tag name</h1>
<h1> select first heading</h1>
<script>
$(document).ready(function(){
$("h1")[0].style.color="blue";
})
</script>
</body>
</html>
Result
select heading by tag name
select first heading
NOTE : if you try to select all tag with same name and given style not working
$("p").style.color="red"; // This code not working