select获取选中项的文字和值

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script src="Scripts/jquery-1.10.2.min.js"></script>
    <script>
        $(function ()
        {
            //alert("a");


            $("#btn_submt").click(function () {

               //alert($("#select").val());//获取选中项的value
               alert($("#select").find("option:selected").text());
                

            });
        })

    </script>
    <title></title>
</head>
<body>
    <form runat="server">
        <select id="select">
            <option value="1">A</option>
             <option value="2">B</option>
        </select>
        <button id="btn_submt" type="button">Submit</button>
    <%--   <asp:Button ID="btn_submt" runat="server" Text="提交" OnClick="btn_submt_Click"  />--%>
        <div>
        </div>
    </form>
    <div runat="server" id="div1"> </div>

</body>
</html>

猜你喜欢

转载自blog.csdn.net/hhw199112/article/details/79204122