首页 > 学院 > 开发设计 > 正文

jquery操作checkbox,radio,select

2019-11-08 18:51:48
字体:
来源:转载
供稿:网友

checkbox

//获取var $chks = $("input[name=chk]:checked");$chks.each(function () { console.log(this.value);});//判断var $cr = $("#cr");$cr.click(function(){ if($cr.is(":checked")){ alert("is"); }else{ alert("no"); }});

radio

//获取//var $radio = $("input:radio[name=gender]:checked");//var $radio = $("input:radio[name=gender][checked]");var v = $radio.get(0).value;//设置$("input:radio[name=gender][value='1']").PRop("checked", true);

select

//获取选中的 下拉框 选项的 valuevar v = $("select option:selected").val();
上一篇:面向对象基础

下一篇:vector的使用

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表