jQuery Tutorial
$('p').css('color', 'blue');
Selects all the paragraph elements.
$('p, #id').css('color', 'blue');
Selects all the paragraph elements and other elements which having id is 'id'.
$('p, #id, .class-name').css('color', 'blue');
Selects all the paragraph elements and other elements which having id 'id' or class name 'class-name'.
<html>
<head>
<title>The jQuery Example - To exclude </title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type = "text/javascript">
$(document).ready(function(event) {
$('p, #id, .class-name').css('color', 'blue');
});
</script>
</head>
<body>
<div id='id'>line 0</div>
<div>line 1</div>
<div>line 2</div>
<p>line 3</p>
<div class="class-name">line 4</div>
<p>line 5</p>
</body>
</html>
Output:
Used tag name, id and class name in the selectors.
Getting all the paragraph elements and other elements which having id 'id' or class name 'class-name'.
« Previous Next »
jQuery Tutorial
Privacy Policy | Copyright
2020 - All Rights Reserved. | Contact us
| Report website issues in Github
| Facebook page
| Google+ page