【发布时间】:2023-03-08 21:55:01
【问题描述】:
为什么这不能正常工作:
<input name="Fuel" type="radio" value="" title="Any" checked="checked">
<input name="Fuel" type="radio" value="1" title="Petrol">
<input name="Fuel" type="radio" value="2" title="Diesel">
<div class="options">Any</div>
<div class="options">Petrol</div>
<div class="options">Diesel</div>
$('.options').click(function(){
$('input').removeAttr('checked');
$('input[title="' + $(this).text() + '"]').attr('checked', 'checked');
});
在此处查看工作示例:
在您尝试重新选择已选择的按钮之前,它可以正常工作。
【问题讨论】:
标签: jquery radio-button