下面是我使用 javascript 更改 td onclick 背景的代码。
window.onload = function () {
document.getElementById('auth').onclick=change;
};
function change(){
this.className="authorised_reporter";
}
如何在单击 td 时同时更改另一个 td 的 css。请参阅我的 html
<td id="main" class="account_holder">
<h1 align="center">Main Account Holder</h1></td>
<td id="auth" class="authorised_reportericon" >
<p align="center" style="color:black;font-size:16px;">Authorised Reporters</p></a>
</td>
我期待的是点击授权记者的 td,那个 td 的背景和主要账户持有人 td 也得到改变。在 javascript 中是否可能。
最佳答案
试试这个
window.onload = function () {
document.getElementById('auth').onclick=change;
};
function change(){
this.className="authorised_reporter";
document.getElementById('main').className="authorised_reporter";
}
关于javascript - 如何调用td的id改变css样式onclick,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16223476/