【发布时间】:2012-02-01 11:12:46
【问题描述】:
我正在尝试设置一个特定的单选按钮项,以便在页面加载时使用 JQuery 进行检查。
这可以用 jquery 完成吗?
【问题讨论】:
标签: jquery
我正在尝试设置一个特定的单选按钮项,以便在页面加载时使用 JQuery 进行检查。
这可以用 jquery 完成吗?
【问题讨论】:
标签: jquery
$(function () {
$("#myRadioId").prop("checked", true);
});
【讨论】:
这很容易用谷歌搜索,最好的学习方法是自己尝试。我们只有通过解决问题才能变得更好。
http://api.jquery.com/ready/
http://api.jquery.com/prop/
$(document).ready(function() {
$("#your id").prop("checked", true);
});
【讨论】:
$(document).ready(function() {
$("#yourRadioButtonId").attr("checked", "checked");
//Or
$("#yourRadioButtonId").prop("checked",true);
});
【讨论】:
$(document).ready(function() {
$('radio-selector[name="the-value-to-set"]').attr('checked', 'checked');
});
【讨论】: