问题:前端jquery经常需要动态设置选中按钮
radio:
设置单选框radio选中:
//获取网页中name=angel的单选按钮,取第一个,添加属性checked=checked,也就是让其选中
//这种方法我没试过
$("input[name=angel]:eq(0)").attr("checked",'checked');
//name value 根据实际更换
$("input[type=radio][name='angel'][value=0]").attr("checked",'checked')
//设置value=2的项目为当前选中项
$("input[type=radio]").attr("checked",'2');
获取单选按钮的值:
$("input[type=radio][name='items']:checked").val();
获取单选按钮是否被选中:
转载radio https://blog.csdn.net/muzi1314_/article/details/76063967
//national 根据实际更换
$('#national').is(':checked')
checkbox:
转载 checkbox https://blog.csdn.net/chenchunlin526/article/details/77448168
转载 checkbox https://blog.csdn.net/qq_35669659/article/details/68485112
select:
转载 select https://www.cnblogs.com/Luouy/p/5806833.html
转载 select https://blog.csdn.net/m_Tenderness/article/details/91898841