View Full Version : Clic div within page => background color/image change?
harlem
10-06-2010, 07:14 AM
I am looking for a script which performs the following:
When I click on a small div box, I want the background of the whole page to change (not the background of the div).
I would like the background to change to another color or another image pattern.
How do I accomplish this?
vwphillips
10-06-2010, 07:39 AM
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
</head>
<body>
<div style="position:absolute;left:100px;top:100px;height:50px;width:50px;background-Color:blue;"
onclick="document.body.style.backgroundColor='red';"
></div>
<div style="position:absolute;left:400px;top:100px;height:50px;width:50px;background-Color:green;"
onclick="document.body.style.backgroundImage='url(http://www.vicsjavascripts.org.uk/StdImages/One.gif)';"
></div>
</body>
</html>
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.