Display the Selected Text and Value of a Item in DropDownList using jQuery


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $('#DropDownList1').bind("change keyup", function () {
                $('#para').html(
"Value: " + $(this).val() +
"<br />" +
" Text: " + $('#DropDownList1 :selected').text());
            });
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:DropDownList ID="DropDownList1" runat="server">
            <asp:ListItem Value="0">Item 0</asp:ListItem>
            <asp:ListItem Value="1">Item 1</asp:ListItem>
            <asp:ListItem Value="2">Item 2</asp:ListItem>
            <asp:ListItem Value="3">Item 3</asp:ListItem>
            <asp:ListItem Value="4">Item 4</asp:ListItem>
        </asp:DropDownList><p id="para"></p>
    </div>
    </form>
</body>
</html>




Do you want more TechChaitu Updates ?
Enter your email address:

Comments

Popular posts from this blog