zoukankan      html  css  js  c++  java
  • jquery获取select选中的值

    误区:

              一直以为jquery获取select中option被选中的文本值,是这样写的:

              $("#s").text();  //获取所有option的文本值

    实际上应该这样:

              $("#s option:selected").text();  //获取选中的option的文本值

    获取select中option的被选中的value值,

               $("#s").val();

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

    js获取select选中的值:

              var sel=document.getElementById("select1"); 

              var index = sel.selectedIndex; // 选中索引

              albumid= sel.options[index].value;//要的值

  • 相关阅读:
    学习进度条64
    学习进度条63
    学习进度条62
    学习进度条61
    学习进度条60
    学习进度条59
    学习进度条58
    学习进度条57
    学习进度条56
    学习进度条55
  • 原文地址:https://www.cnblogs.com/mailan/p/4891572.html
Copyright © 2011-2022 走看看