2010-09-03 35 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