2010-09-03 3 views
0

J'ai des boutons sur une page et lorsque l'utilisateur clique sur ce bouton, la couleur de la page change. Fondamentalement, je crée un changeur de thème. mon code est le suivant:Theme Changer- Help

fonction rouge() { var Redbtn = document.getElementById ("btnRed"); Redbtn.bgColor = "# F00"; } fonction bleue() { }

changeur Thème

i have done upto the red button but the color of the page do not appears to be red.. please help where i obtiens problème.

Répondre

0

dans votre html,

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

dans votre fichier js,

$ (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'); 
}); 

});

+0

code pourrait être nettoyé je suis sûr – Rahul