<select id="sed">    <option value="1">张三</option>
</select>我现在要用js写拿到张三 不要他的value值 要文本值。JavaScriptjQueryselectoption

解决方案 »

  1.   

    js:
     var tem = document.getElementById("sed");
     alert(tem.options[tem.selectedIndex].text)
    jquery:
     alert($("#sed option:selected").text());
      

  2.   


    <html>
    <head>
    <script>
    function show()
    {
      var sed=document.getElementById("sed");
      var txt=sed.options[sed.selectedIndex].innerText;
      alert(txt);
    }
    </script>
    </head>
    <body >
    <select id="sed" onchange="show()">
     
        <option value="1" selected>张三</option>
    <option value="2">李四</option>
    <option value="3">王五</option>
     </select>
    </body>
    </html>
      

  3.   

    JQUERYencodeURIComponent($("#ddlProductType").find('option:selected').text())如果作为参数传递需要编码。