我手动选中了使用.attr('checked', true);
的单选按钮(因为prop('checked', true);
在我的情况下似乎没有做任何事情)。尽管将“checked”属性设置为“checked”,jQuery选中的单选按钮仍未被检查
虽然单选按钮确实得到checked
在标记属性等于checked
,单选按钮还没有选中(视觉上的页面上,所有单选按钮处于未选中状态)。
这怎么可能?
jQuery的:获得
$('.variations_fieldset input[value="Every 2 months"]').attr('checked', true);
HTML:
<fieldset class="variations_fieldset">
<input type="radio" data-attribute_name="attribute_billing" name="attribute_billing" id="billing1" value="Once Off">
<label for="billing1">Once Off</label>
<input type="radio" data-attribute_name="attribute_billing" name="attribute_billing" id="billing2" value="Every 1 month">
<label for="billing2">Every 1 month</label>
<input type="radio" data-attribute_name="attribute_billing" name="attribute_billing" id="billing3" value="Every 2 months" checked="checked">
<label for="billing3">Every 2 months</label>
</fieldset>
请张贴一个完整的代码示例。 – j08691
你使用任何插件的单选按钮像CSS样式? –
是的,但是CSS可以防止单选按钮被查看,即使它确实被检查过吗? – drake035