| Next Tip?
Home » Javascript

Changing BackGround Color using JavaScript

2 July 2009 1,882 views 3 Comments
1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 4.50 out of 5)
Loading ... Loading ...

The following code shows how on button click event we can change the background color of the page.

<!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" >

<head>

<title>Changing the Backgound color on Button Click–Meetu</title>

<script language=”javascript” type=”text/javascript”>

function prog1()

{

document.bgColor=“red”;

}

function prog2()

{

document.bgColor=“green”;

}

</script>

</head>

<body>

<input id=”Button1″ type=”button” value=”green” onclick=”prog2()” />

<input id=”Button2″ type=”button” value=”red” onclick=”prog1()” /></body></html>

Thanks and Regards

Meetu Choudhary

Go Green Save Green

Popularity: 31%

Post to Twitter Tweet This Post

Related posts:

  1. Use CSS and JavaScript in textbox in .aspx page Use CSS and JavaScript in textbox in .aspx page. Create...
  2. Describing window.open method Using the window.open method by Gaurav Arora The syntax of...
  3. Changing Label Properties at run time –> Changing Label Properties at run time To change...
  4. Changing properties of textbox in visual studio 2010 Changing properties of textbox in visual studio 2010 To...

Related posts brought to you by Yet Another Related Posts Plugin.

Ads by Lake Quincy Media

3 Comments »

  • Gaurav Arora said:

    Testing

    ?
  • shuby said:

    great work!

  • RD said:

    Shuby I would say cool one and intresting. not the great one as i have seen other posts bys her too. they are Great.

Leave your response!

You must be logged in to post a comment.

Get Adobe Flash playerPlugin by wpburn.com wordpress themes