91名师指路-头部
91名师指路

jquery 获取下拉框单选框选中的值,添加移除属性

由于某些原因,现在不支持支付宝支付,如需要购买源码请加博主微信进行购买,微信号:13248254750

1 获取下拉框选中的值

$("#articleType option:selected").val();

2 获取单选框选中的值

$("input[name='isSourceCode']:checked").val();

3 追加属性

$(".reprintUrl").attr("novalidate", "novalidate");

4 移除属性

$(".reprintUrl").removeAttr("novalidate");

5 设置第一个Radio为选中值

$('input:radio:first').attr('checked', 'checked'); 或者 $('input:radio:first').attr('checked', 'true');

6 设置最后一个 radio为选中值

$('input:radio:last').attr('checked', 'checked'); 或者$('input:radio:last').attr('checked', 'true');

7 根据索引值设置任意一个radio为选中值

$('input:radio').eq(索引值).attr('checked', 'true');索引值=0,1,2....

8 根据Value值设置 radio为选中值

$("input:radio[value='rd2']").attr('checked','true');

9 删除Value值为rd2的radio

$("input:radio[value='rd2']").remove();

10 删除第几个radio

$("input:radio").eq(索引值).remove();索引值=0,1,2....

11 遍历radio

$('input:radio').each(function(index,domEle){

// 自己的代码

});


2019-08-16 20:46:28     阅读(940)

名师出品,必属精品    https://www.91mszl.com

联系博主    
用户登录遮罩层
x

账号登录

91名师指路-底部