当对特定 DIV 执行单击操作时,我想选择一个 RADIO 按钮
。我正在使用以下代码,它工作正常,但根据他们的说法,它没有被 W3 验证,我不能在 LABEL 标签内使用 DIV 标签。我不喜欢 JQuery,因为可以在适当的位置使用 LABEL 完成整个工作
以下是我的代码
<div class="col-md-4 col-sm-4 padding"><label style="height:100%; width:100%;">
<div class="boxtyle2">
<div class="checkbox">
<div class="donate-option-box">
<input type="radio" checked="checked" onclick="ChangeGivingTextColor('10');" class="styled" value="10" name="asd">
</div>
<h4 id="giving10" style="color: rgb(241, 55, 133);"><span class="pink2 currencysymbol">$</span>10</h4>Text
</div>
<div class="clear"></div>
</div><!--boxtyle2-->
</label></div>
有人可以修改我的代码,以便我可以将它与 LABEL 一起使用,但是如果没有 LABEL 选项,那么我应该在 JQuery 中做什么?
最佳答案
这是您可以在 div 元素上选择单选 onclick 的代码。
$("div").on("click", function(){
$("input[type='radio']").prop("checked", true);
});
关于jquery - 在 DIV 上选择单选 OnClick,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22163199/