如何启用单选按钮点击带有 3 张图片的按钮?
<div class="newsRadioButtons">
<div class="radioAll">
<div class="radioAllLeft"></div>
<div class="radioAllMiddle">
<imput type="radio" checked="true" value="all" name="filter" />ALL
</div>
<div class="radioAllRight"></div>
</div>
<div class="radioImportant">
<div class="radioImportantLeft"></div>
<div class="radioImportantMiddle">
<imput type="radio" checked="true" value="all" name="filter" />Important
</div>
<div class="radioImportantRight"></div>
</div>
对不起打字错误
最佳答案
首先,请注意您写的是 imput 而不是 input。 至于解决方案,使用 jquery 可以将事件附加到周围的 div,这样当单击 div 时,将检查他内部的输入元素。
$('.newsRadioButtons > div').on('click', function(e) {
$(this).find('input').prop('checked', true);
});
关于jquery - 滑动门单选按钮,如何启用点击/选中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9768076/