Practical- 20.
2
Aim-use javascript to perform operation to change background colour of
webpage as selceted by user from a list of colurs given in combo box.
<DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Change the background colour dynamically with Javascript</title>
<script>
function changeBodyBg(color)
{
document.body.style.background=colour;
}
functiochangeheadingbg (colour)
{
document.getElementById("heading").style.background=colour;
}
</script>
</head>
<h1 id="heading">Change Background Colour</h1>
<p> Different colour</p>
<hr>
<div>
<label>Change Webpage Background to:-</label>
<button type ="button"onclick="changebodyBg('lime');">lime</button>
<buttoon type
="button"onclick=changebodyBg('yellow')">yellow</button>
<button
type="button"onclick="changebodyBg('magenta')">magenta</button>
</hr>
</div>
<br><div>
<label>ChangeHeading Background TO:</label>
<button
type="button"onclick="changeHeadingBg('black');">black</button>
<button type="button"onclick="changeHeadingBg('lime');">lime</button>
<button
type="button"onclick="changeHeadingBg('yellow');">yellow</button>
</div>
</body>
</html>
Practical – 20