gpt4 book ai didi

jquery - 使用 jquery 更改 html 标签的背景

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

<div id="lifecycleStage">
<div id="private2">
<input type="radio" name="lifecyclePrivate" value="preliminary" id="preliminary"/> <label for="preliminary">Preliminary</label>
<input type="radio" name="lifecyclePrivate" value="prelist" id="prelist"/> <label for="prelist">Prelist</label>
<input type="radio" name="lifecyclePrivate" value="retired" id="retired"/> <label for="retired">Retired</label> <br>
<input type="radio" name="lifecyclePrivate" value="internal product" id="internalProduct"/> <label for="internalProduct">Internal Product</label>
<input type="radio" name="lifecyclePrivate" value="reference nop" id="referenceNOP"/> <label for="referenceNOP">Reference NOP</label>
</div>
<div id="public">
<input type="radio" name="lifecyclePublic" value="listed" id="listed"/> <label for="listed">Listed ................</label>
<input type="radio" name="lifecyclePublic" value="approaching op" id="approachingOP"/> <label for="approachingOP">Approaching OP</label>
<input type="radio" name="lifecyclePublic" value="no longer available" id="noLongerAvailable"/><label for="noLongerAvailable">No Longer Available</label>
</div>

我想要的是将所选标签的背景更改为不同的“独特”颜色。例如,当选择 prelist 时,它有蓝色背景,但当选择 retired 时,它有黑色背景。

任何提示和技巧,非常感谢!

最佳答案

为什么要使用 jQuery?只需使用 CSS:

label {
background-color: #000;
}

input[type=radio]:checked + label {
background-color: #00f;
}

JS Fiddle demo .

关于jquery - 使用 jquery 更改 html 标签的背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15210472/

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