We would like to know how to change page background colour on button click.
<!-- ww w. j av a2s .c om-->
<!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(){
$( "#change_background" ).on( "click", function() {
$("body").first().css("background-color","red");
});
});
</script>
</head>
<body>
<input type="button" id="change_background" value="Change background" />
</body>
</html>
The code above is rendered as follows: