2010-09-03 44 views
0

我有一个页面上的按钮,当用户点击该按钮时,页面的颜色会改变。基本上我正在创造一个主题转换器。我的代码是这样的:Theme Changer-帮助

功能红色() { 变种Redbtn =的document.getElementById( “btnRed”); Redbtn.bgColor =“#F00”; } 功能蓝() { }

主题变换器

have done upto the red button but the color of the page do not appears to be red.. please help where i m到处问题。

在你的HTML

回答

0

<button class="button" id="redButton" /> Red </button> 
<button class="button" id="blueButton" /> Blue </button> 
<button class="button" id="greenButton" /> Green </button> 
在js文件

$(文件)。就绪(函数(){

$('#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

代码可以清理干净我很确定 – Rahul 2010-09-03 10:05:33