views:

14

answers:

1

i have buttons on a page and when the user clicks onto that button, the color of the page changes. basically i`m creating a theme changer. my code is this :

function Red() { var Redbtn = document.getElementById("btnRed"); Redbtn.bgColor = "#F00"; } function Blue() { }

Theme changer

ihave done upto the red button but the color of the page do not appears to be red.. please help where im getting problem.

A: 

in your html,

<button class="button" id="redButton" /> Red </button>
<button class="button" id="blueButton" /> Blue </button>
<button class="button" id="greenButton" /> Green </button>

in your js file,

$(document).ready(function(){

$('#redButton').click(function() {
    $('body').css('background-color', '#FF0000');
});

$('#greenButton').click(function() {
    $('body').css('background-color', '#00FF00');
});

$('#blueButton').click(function() {
    $('body').css('background-color', '#0000FF');
}); 

});

Rahul
code could be cleaned up i am sure
Rahul