This option will reset the home page of this site. Restoring any closed widgets or categories.

Reset

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>

DEMO

VN:F [1.5.7_846]
Rating: 0.0/10 (0 votes cast)
VN:F [1.5.7_846]
Rating: 0 (from 0 votes)

Related posts:

  1. Change background color using php for a webpage
  2. Adding and removing child nodes using javascript and DOM
  3. View webpage source using javascript
  4. Simple Javascript Clock
  5. Load Another Webpage Content Using Simple Jquery
  6. Password protect pages using javascript
  7. Simple Javascript Slideshow

Leave a Reply

Comments (required)

Spam Protected