Jquery mobile中的 checkbox和radio的设置问题

在Jquery Mobile网页中用JS控制Radio的状态一直达不到目的。

用$("input[name='radio']:first").prop("checked",true)设置checked的时候,用.attr("checked")读取不到值。

用$("input[name='radio']:first").attr("checked",true)设置checked的时候,页面显示状态变为两个都不显示。

最后只能把prop和attr都写在里面,才算解决了问题。

当然最后的refresh也是必须的,否则也不更新状态。

$("input[name='radio']:first").prop("checked",true).checkboxradio('refresh');
$("input[name='radio']:first").attr("checked",true).checkboxradio('refresh');
$("input[name='radio']:last").attr("checked",false).checkboxradio('refresh');
$("input[name='radio']:last").prop("checked",false).checkboxradio('refresh');

原文地址:https://www.cnblogs.com/billybobby/p/7055715.html