0
What is JQuery selector in Web development?
What is JQuery selector in Web development?
$(“tag-name”).function ()
<!DOCTYPE html>
<html>
<head>
<script src='https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js'></script>
<script>
$(document).ready(function () {
$('button').click(function () {
$('p').css({'background-color':'yellow'});
});
});
</script>
<style>
</style>
</head>
<body>
<p>Click me for hiding the data </p>
<p>Click me again </p>
<p>Click me again and again </p>
<button>Click Me for change the paragraph color</button>
</body>
</html>
$(“#id-name”).function ()
<!DOCTYPE html>
<html>
<head>
<script src='https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js'></script>
<script>
$(document).ready(function () {
$('button').click(function () {
$('#p3').css({ 'background-color': 'yellow' });
$('#p2').css({ 'background-color': 'blue' });
$('#p1').css({ 'background-color': 'red' });
});
});
</script>
<style>
</style>
</head>
<body>
<p id='p1'>This is #p1</p>
<p id='p2'>This is #p2</p>
<p id='p3'>This is #p3 </p>
<button>Click Me for change the paragraph color using id selector</button>
</body>
</html>
$(“.class-name”).function ()
<!DOCTYPE html>
<html>
<head>
<script src='https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js'></script>
<script>
$(document).ready(function () {
$('button').click(function () {
$('.cls1').css({ 'background-color': 'yellow' });
$('.cls3').css({ 'background-color': 'blue' });
$('.cls2').css({ 'background-color': 'red' });
});
});
</script>
<style>
</style>
</head>
<body>
<p class='cls1'>This is .cls1</p>
<p class='cls2'>This is .cls2</p>
<p class='cls3'>This is .cls3</p>
<button>Click Me for change the paragraph color using id selector</button>
</body>
</html>