0% found this document useful (0 votes)
14 views3 pages

20 1

Uploaded by

riddhipatel5820
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views3 pages

20 1

Uploaded by

riddhipatel5820
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

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

You might also like