<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("p").css("background-color", "yellow");
});
});
</script>
</head>
<body>
<h2>This is a heading</h2>
<p style="background-color:#ff0000">Thankyou workingcode.in</p>
<p style="background-color:#00ff00">Thankyou workingcode.in</p>
<p style="background-color:#0000ff">Thankyou workingcode.in</p>
<p>This is a paragraph.</p>
<button>Set background-color of p</button>
</body>
</html>
How to Set a CSS Property in JQuery
admin Changed status to publish December 26, 2023