[英]how to change the color of a button using onclick on other button using javascript or ajax
我想通過單擊g.php
上的按鈕來更改頁面g.php
上的按鈕s.php
。 g.php
已包含在s.php
。 那么,有可能嗎? 如果你回答我,我將非常感謝你。
要在javascript函數中更改按鈕的顏色,請使用以下代碼:
document.getElementById("button").style.background='#000000';
嘗試這個,
$("#button1id").click(function(){
$("#button2id").css("color","red");
})
如果您在同一頁面中呈現了這兩個按鈕,請添加一些標識符,例如<button id="btn1" /> <button id="btn2"/>
然后使用例如jQuery框架並編寫此代碼$(document).ready(function(){ $("#btn1").on("click",function(){ $("#btn2").css("background-color","yourcolor")}); });
編輯:對不起我的代碼中有錯誤我已經改變})to)},無論如何這里是工作exapmle
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.