2012-08-06 89 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