整理盘点常见的jquery操作input radio单选按钮的操作:
html代码
<div style="float: left; width: 70%; margin-top:20px;" id="subjectResp">
<label class="radio-inline"><input type="radio" id="bzjt" name="typeTag" value="01" checked>班子集体责任</label>
<label class="radio-inline"><input type="radio" name="typeTag" value="02">一把手责任</label>
<label class="radio-inline"><input type="radio" name="typeTag" value="03">分管领导责任</label>
</div>
1.设置单选按钮选中操作
jquery版本大于等于1.6使用如下方法:
$("#bzjt").prop("checked", true);
jquery版本小于1.6使用如下方法:
$("#bzjt").attr('checked', 'checked');
2.获取点击操作事件
$('input:radio[name=typeTag]').click(function() {
alert(this.value);
});
3.设置change事件
$('input:radio[name=typeTag]').change(function() {
alert(this.value);
});
4.获取当前被选中的单选按钮
方法1:
var typeTag = '';
$('input:radio[name=typeTag]').each(function () {
if(this.checked == true){
typeTag = this.value;
}
});
方法2:
var typeTag = $("input[type='radio'][name='typeTag']:checked").val()
- https://www.haorooms.com/post/checkandselect
- https://stackoverflow.com/questions/13152927/how-to-use-radio-on-change-event
最新评论
小米电视,安装成功后出现加入微信公众号的对话框,按遥控器按键无法消除,导致软件无法使用!!!!!
电视电台直播3.9,无法观看港澳台!还要下载新版本,不知道去哪里下载,麻烦你们给看看。
阿里和度盘都挂了
百度和阿里的链接都挂了
密码不对啊
阿里云盘也用不了
哥,分享一下
密码是啥