<legend>P1</legend> <table> <tr> <th scope="row"><label>Link State</label></th> <td><span id="wr1_link">-</span></td> </tr> <tr> <th scope="row"><label>Lock State</label></th> <td><span id="wr1_lock">-</span></td> </tr> <tr> <th scope="row"><label>Sync State</label></th> <td><span id="wr1_sync">-</span></td> </tr> <tr> <th scope="row"><label>Tranceive Bytes</label></th> <td><span id="wr1_tranceive">-</span></td> </tr> <tr> <th scope="row"><label>Sync Source</label></th> <td><span id="wr1_source">-</span></td> </tr> <tr> <th scope="row"><label>Loopback Time(ps)</label></th> <td><span id="wr1_loopback">-</span></td> </tr> <tr> <th scope="row"><label>Oneway Time(ps)</label></th> <td><span id="wr1_oneway">-</span></td> </tr> <tr> <th scope="row"><label>Link Time</label></th> <td><span id="wr1_linktime">-</span></td> </tr> </table> <legend>P2</legend> <table> <tr> <th scope="row"><label>Link State</label></th> <td><span id="wr0_link">-</span></td> </tr> <tr> <th scope="row"><label>Lock State</label></th> <td><span id="wr0_lock">-</span></td> </tr> <tr> <th scope="row"><label>Sync State</label></th> <td><span id="wr0_sync">-</span></td> </tr> <tr> <th scope="row"><label>Tranceive Bytes</label></th> <td><span id="wr0_tranceive">-</span></td> </tr> <tr> <th scope="row"><label>Sync Source</label></th> <td><span id="wr0_source">-</span></td> </tr> <tr> <th scope="row"><label>Loopback Time(ps)</label></th> <td><span id="wr0_loopback">-</span></td> </tr> <tr> <th scope="row"><label>Oneway Time(ps)</label></th> <td><span id="wr0_oneway">-</span></td> </tr> <tr> <th scope="row"><label>Link Time</label></th> <td><span id="wr0_linktime">-</span></td> </tr> </table> 判断wr0_link的值 如果值为1 则让P2的表格亮一点 让P1的表格灰一点 如果值为0 则让P1的表格亮一点 P2的表格灰一点
时间: 2023-07-09 11:16:47 浏览: 98
根据你提供的代码,我可以给出如下的JavaScript代码来实现你的要求:
```
var wr0_link = document.getElementById("wr0_link").innerText;
if (wr0_link == "1") {
// 如果 wr0_link 值为 1,则让 P2 的表格亮一点,让 P1 的表格灰一点
document.querySelector("legend:nth-of-type(2)").style.opacity = "1";
document.querySelector("legend:nth-of-type(1)").style.opacity = "0.5";
} else if (wr0_link == "0") {
// 如果 wr0_link 值为 0,则让 P1 的表格亮一点,让 P2 的表格灰一点
document.querySelector("legend:nth-of-type(1)").style.opacity = "1";
document.querySelector("legend:nth-of-type(2)").style.opacity = "0.5";
}
```
这段代码的作用是获取 ID 为 `wr0_link` 的元素的文本内容(即 `wr0_link` 的值),然后根据值的不同设置两个 `<legend>` 元素的不透明度,从而实现让 P1 或 P2 的表格亮一点的效果。
阅读全文