Change Background color of a web page using onmouseover property

HTMLWeb DevelopmentFront End Technology

The onmouseover property allows you set a script when the mouse pointer is moved onto an element. To change the background color, use the HTML DOM backgroundColor property.

Let us see an example to implement the onmouseover property and change the background color −

Example

 Live Demo

<!DOCTYPE html>
<html>
<body>
<h2>Heading Two</h2>
   <a onmouseover="document.body.style.backgroundColor ='orange'">Hover over me to change the background color.</a><br>
</body>
</html>

Output

Now hover over the text to change the background color of the web page −

raja
Published on 20-Jun-2019 12:25:13
Advertisements