1、页面加载时根据值自动选中。
$("#bookLevel option[value='${textbook.bookLevel}']").attr("selected",true);
2、获取页面radio选中的值。
$('input[name="testradio"]:checked').val();
$('input:radio:checked').val();
$('input[@name="testradio"][checked]');
$('input[name="testradio"]').filter(':checked');
以上name或id需要替换成你定义的。
本文介绍了如何使用jQuery来设置页面元素的状态,如在页面加载时自动选中某个选项,以及如何获取页面上被选中的radio按钮的值。文中提供了具体的代码示例,并解释了这些操作的具体实现方式。
2123

被折叠的 条评论
为什么被折叠?



