2 回答
TA贡献1780条经验 获得超1个赞
您在YES或NO文本中使用任何元素
$(document).ready(function() {
$("input[type=radio]").click(function(e) {
$(this).next("span").css("border","2px solid red");
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<form name="input" method="get">
<span>Registered:</span>
<input type="radio" name="registered" value="yes">
<span>YES</span>
<input type="radio" name="registered" value="no" checked disabled>
<span>NO</span>
</form>
TA贡献1876条经验 获得超5个赞
不需要javascript。您可以使用:checked选择器。你也应该用 span 包裹你的文本。
input[type="radio"]:checked:not(:disabled) + span{
border: 2px solid red;
}
<form name="input" method="get">
<span>Registered:</span>
<input type="radio" name="registered" value="yes"><span>YES</span>
<input type="radio" name="registered" value="no" checked disabled><span>NO</span>
</form>
添加回答
举报