Javascript Style How to - Change background color








Question

We would like to know how to change background color.

Answer


<!DOCTYPE html>
<html>
<head>
</head><!--from   w  w w .j a  v  a 2 s .  c  o  m-->
<body>
  <div id="testing" 
       onmouseover="this.style.backgroundColor='red';" 
       onmouseout="this.style.backgroundColor='blue';">
    This is a testing ...</div>
</body>
</html>

The code above is rendered as follows: