how to get drop down selected value in jQuery

Total Post:25

Points:175
JQuery 
 218  View(s)
Ratings:
Rate this:

how to get drop down selected value in jQuery

  1. Post:140

    Points:984
    Re: how to get drop down selected value in jQuery

    Drop down value in jQuery :

    HTML Markup consists of an HTML Select DropDownList and a Button.

    For single select dom elements, to get the currently selected value:

    $('#dropDownId').val(); 
    $('#dropDownId :selected').text(); // currently selected text

    Ex:  Select color: 

    <select id="favcolor">
    
        <option value=""></option>
        <option value="1">Red</option>
        <option value="2">Blue</option>
        <option value="3">Black</option>
    </select>
        <input type="button" id = "btnGet" value="Get Selected Text Value" />
        $(function () {
            $("#btnGet").click(function () {
                var selectedValue = $("favcolor").val();
                alert("Selected Value:" Value: "+ selectedValue);
            });
        });
    </script>

    Happy Coding :)

Answer