jquery设置、判断、获取input单选标签选中状态


1、设置某项单选input为选中状态:
$("input[type='radio']").eq(1).attr('checked',true);
②也可设其属性checked为'checked',设置完后原选中项会自动取消选中
$("input[type='radio']").eq(1).attr('checked','checked');
2、判断某单选框是否被选中状态:
❶ 使用object.attr('checked')==true是错的,应使用object.attr('checked')=='checked'作判断
$("input[type='radio']").eq(1).attr('checked')=='checked';
❷也可使用 is(':checked')方法作判断
$("input[type='radio']").eq(1).is(':checked');
3、获取被选中的单选框:使用 :checked 方法
$("input[type='radio']:checked");

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM