Change the background color of the div element of the following code on clicking the button.

<!DOCTYPE html>

<html>

<head>

         <title></title>

         <script

  src="https://code.jquery.com/jquery-3.5.1.slim.min.js"

  integrity="sha256-4+XzXVhsDmqanXGHaHvgh1gMQKX40OUvDEBTu8JcmNs="

  crossorigin="anonymous"></script>

</head>

<body>

         <div style="height: 400px;width:400px">

         </div>

<button>set color in div</button>

<script type="text/javascript">

         $("button").click(function(){

    $("div").css("background","red");

         })

</script>

</body>

</html>


Post a Comment

If you have any doubts, Please let me know
Thanks!

Previous Post Next Post