jQuery change select option value and text – How to get selected text from a drop-down list using jQuery?

jQuery change select option value and text – get the selected text (not the selected value) from a drop-down list in jQuery.

jQuery change select option value and text

You can use the jQuery :selected selector in combination with the text() method. To get the selected text, we can use the following JQuery code.

$("#yourdropdownid option:selected").text();

Get selected text from a drop-down list (select box) using jQuery – We can select text or we can also find the position of a text in a drop down list using option:selected attribute.

Read Also:  Codeigniter Form Validation with Google reCAPTCHA

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

Get Selected Option Text of HTML SELECT using jQuery

<select id="allTeam">
    <option value="1">Yes</option>
    <option value="2">No</option>
</select>
<input type="button" id="player" value = "Player" />
<script type="text/javascript">
    $("#player").live("click", function () {
        //Get text or inner html of the selected option
        var selectedText = $("#allTeam option:selected").html();
        alert(selectedText);
    });
</script>

How to Get the Text Value of Selected Option using jQuery?

HTML Code

<select id="memberList">
    <option value="1">Member 1</option>
    <option value="2">Member 2</option>
    <option value="3">Member 3</option>
    <option value="4">Member 4</option>
    <option value="5">Member 5</option>
</select>

Don’t Miss : jquery selected option text.

$(document).ready(function(){
    $('#memberList').on('change',function(){
        //var optionValue = $(this).val();
        //var memberTxt = $('#memberList option[value="'+optionValue+'"]').text();
        var memberTxt = $("#memberList option:selected").text();
        alert("Selected Option Text: "+memberTxt);
    });
});

I hope you get an idea about jQuery change select option value and text.
I would like to have feedback on my infinityknow.com.
Your valuable feedback, question, or comments about this Article are always welcome.
If you enjoyed and liked this post, don’t forget to share.