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 ch开发者_StackOverflow中文版anger. 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 i
m getting problem.
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');
});
});
精彩评论