2012-08-06 27 views

回答

1

要更改按鈕的顏色在JavaScript函數中使用下面的代碼:

document.getElementById("button").style.background='#000000'; 
0

如果在同一頁面呈現的兩個按鈕,將它們添加一些identificators像<button id="btn1" /> <button id="btn2"/>,比使用例如jQuery框架和寫這個代碼$(document).ready(function(){ $("#btn1").on("click",function(){ $("#btn2").css("background-color","yourcolor")}); });

編輯:對不起,我已經在我的代碼中的錯誤,我已經改變})到)},反正這裏工作exapmle

http://jsfiddle.net/t5YRT/

+0

它givinng一些語法錯誤 – user1578460 2012-08-06 14:35:55

+0

很好,你已經列入到您的網頁jQuery腳本文件? – david 2012-08-06 16:09:22

+0

你好,我已經這樣做了, user1578460 2012-08-06 19:38:35

1

試試這個,

$("#button1id").click(function(){ 
    $("#button2id").css("color","red"); 
}) 
+0

它不工作,因爲這兩個按鈕都在不同的頁面上 – user1578460 2012-08-06 14:36:45

相關問題