jQuery Style How to - Change background color to alert








Question

We would like to know how to change background color to alert.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.11.0.js'></script>
<script type='text/javascript'>
$(window).load(function(){<!--from   w w  w. j av a 2s  .co  m-->
    $("#b").click(function(e){
      $("body").css("background-color","yellow");
      console.log("background-color has changed successfully");
      e.preventDefault();
    });
});
</script>
</head>
<body>
  <a href="javascript:void(0);" id="b">Click</a>
</body>
</html>

The code above is rendered as follows: