打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Jquery 操作 Select checkbox radio
获取值:
文本框,文本区域:$("#username").attr("value");
多选框checkbox:$("#checkbox_id").attr("value");
单选组radio:   $("input[@type=radio][@checked]").val();
下拉框select: $('#departid').val();
 
<input type="radio" name="istop" value="1"/>
<input type="radio" name="istop" value="0"/>
获取选中radio的值:var item = $("input[name=istop]:checked").val();
 
JQuery获取和设置Select选项
选中第一项1:$("#departid").get(0).options[0].selected = true;
选中第一项2:$("#departid").get(0).selectedIndex = 0;
清空 Select : $("#departid").empty();
获取Select :
获取select 选中的 text :$("#departid").find("option:selected").text();
获取select选中的 value: $("#departid").val();
获取select选中的索引: $("#departid").get(0).selectedIndex;
设置select 选中的text:
  var count=$("#departid option").length;
  for(var i=0;i<count;i++) 
     {           if($("#departid").get(0).options[i].text == text) 
        { 
            $("#departid").get(0).options[i].selected = true; 
         
            break; 
        } 
    }
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
jquery获取框值的数据,收藏一下吧
.val() | jQuery API Documentation
jQuery获取Radio选择的Value值:
jQuery的一些备忘
JQUERY获取text,areatext,radio,checkbox,select值
jquery
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服