Please login to start chat

ICT Solutions 22 Jun 2022, 18:04:53
Category : JavaScript Tutorials

Change Background Color of Html Elements

<!DOCTYPE html>
<html>
<head>
<title>JS Code Testing</title>
</head>
<body>
<table style = "width:300px; height:100px">
<tr>
<td onmouseover = "bgChange(this.style.backgroundColor)";
onmouseout = "bgChange('transparent')";
style = "background-color:red"></td>
<td onmouseover = "bgChange(this.style.backgroundColor)";
onmouseout = "bgChange('transparent')";
style = "background-color:green"></td>
<td onmouseover = "bgChange(this.style.backgroundColor)";
onmouseout = "bgChange('transparent')";
style = "background-color:yellow"></td>
</tr>
</table>
<script>
function bgChange(bg){
document.body.style.background = bg;
}
</script>
</body>
</html>

Comments:

No comment to show.

Available Services
Download Android Application