Change webpage background color using javascript
Hello guys, i am back again with yet another simple but interesting tutorial of changing webpage background color using javascript, just copy and paste it to your webpage and customize it according to your webpage design.
<script language=”javascript”>
function chngebg (id)
{
switch (id)
{
case ‘b1′:
document.body.bgColor = “red”;
break;
case ‘b2′:
document.body.bgColor = “blue”;
break;
case ‘b3′:
document.body.bgColor = “black”;
break;
case ‘b4′:
document.body.bgColor = “yellow”;
break;
}
}
</script>
<body>
<input type=”button” id=”b1″ onclick=”chngebg(this.id)” value=”Red”/>
<input type=”button” id=”b2″ onclick=”chngebg(this.id)” value=”Blue”/>
<input type=”button” id=”b3″ onclick=”chngebg(this.id)” value=”Black”/>
<input type=”button” id=”b4″ onclick=”chngebg(this.id)” value=”Yellow”/>
</body>
Related posts:
- Change background color using php for a webpage
- Adding and removing child nodes using javascript and DOM
- View webpage source using javascript
- Simple Javascript Clock
- Load Another Webpage Content Using Simple Jquery
- Password protect pages using javascript
- Simple Javascript Slideshow
