gpt4 book ai didi

html - 使用 CSS 查找复选框的标签

转载 作者:太空宇宙 更新时间:2023-11-03 17:54:11 25 4
gpt4 key购买 nike

我正在尝试将标准复选框更改为字体很棒的版本。问题是我不能更改 HTML,因为它是生成的,我也不能使用 jQuery。有没有办法在下面的 html 中“找到”我的复选框的标签并更改标签:在复选框之前为真或假?

编辑:我想我可能有点不清楚,完整的代码包括一个 javascript,这让我无法在不更改它的情况下使用 javascript。此外,labeltext 的类是常用的,也可以是 -1 或 -2。

<table cellpadding="0" cellspacing="0" class="odincategory odincategory38 odincategory-even odincategory-placement2 odincategory-placement-even odincategory-multi" id="odincategory38-holder">
<tbody>
<tr>
<td class="odincategorycheckcolumn">
<input type="checkbox" name="odinanswer1" value="38" class="odincategorycheckmulti" id="odincategory38">
</td>
<td class="odincategorylabelcolumn">
<table cellpadding="0" cellspacing="0" id="odincategorylabel38">
<tbody>
<tr>
<td class="odincategorylabel">
<label for="odincategory38"><span class="odinfontnumber-0">Choice<br>
</span></label>
</td>
</tr>
</tbody>
</table>
</td>
<td class="odincategorymarkcolumn"></td>
</tr>
</tbody>
</table>

最佳答案

这不能使用纯 CSS 来完成。问题是您只能选择相邻的、跟随的或降序的元素。在您的情况下,标签位于文档树中的其他位置。如果你可以在复选框旁边添加标签,你可以做类似的事情

input[type=checkbox] + label {
color: green;
}
input[type=checkbox]:checked + label {
color: red;
}

但这不适用于您的代码。

关于html - 使用 CSS 查找复选框的标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26671355/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com