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

Posted 比利

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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‘);




以上是关于Jquery mobile中的 checkbox和radio的设置问题的主要内容,如果未能解决你的问题,请参考以下文章

从 jQuery Mobile 重置值

jquery mobile各类标签的refresh

jQuery mobile - 动态切换选择菜单到多个

JQuery mobile动态添加切换开关到listview

jquery mobile中的固定标题滚动/拖动

在 jQuery Mobile 中的 Ajax 调用中显示页面加载微调器