Javascript Style How to - Change background image to Gradients








Question

We would like to know how to change background image to Gradients.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'>
window.onload=function(){<!--   w  ww  .j  a  va2  s.c  o m-->
   document.body.style.backgroundImage = "radial-gradient(red, black)"; 
}
</script>
</head>
<body>
</body>
</html>

The code above is rendered as follows: