我尝试用jQueryMobile1.3.2复制这个例子,但它只适用于1.2.1或更低版本。
$(document).on("pageinit", "#page1", function(){
$("#checkFirst").click(function(){
$("input[type='radio']:first").attr("checked", "checked");
$("input[type='radio']").checkboxradio("refresh");
});
$("#checkSecond").click(function(){
$("input[type='radio']:eq(1)").attr("checked", "checked");
$("input[type='radio']").checkboxradio("refresh");
});
$("#checkLast").click(function(){
$("input[type='radio']:last").attr("checked", "checked");
$("input[type='radio']").checkboxradio("refresh");
});
$("#uncheckAll").click(function(){
$("input[type='radio'][checked]").removeAttr("checked");
$("input[type='radio']").checkboxradio("refresh");
});
});此功能只为jqm > 1.2.1中的一个无线电按钮重新绘制第一次无线电按钮。
这链接到jsfiddle:
带有1.2.1的Works版本
不要使用1.3.2版本
知道为什么这个例子在其他版本中不起作用吗?
发布于 2013-10-01 08:07:38
使用.prop()而不是.attr()
//to check
$("input[type='radio']:first").prop("checked", true);
//to uncheck
$("input[type='radio']:first").prop("checked", false);读:属性与属性
发布于 2013-10-01 08:08:39
https://stackoverflow.com/questions/19111017
复制相似问题