Get text of the selected option with jQuery

This question already has an answer here:

  • Get selected text from a drop-down list (select box) using jQuery 29 answers

  • 关闭,你可以使用

    $('#select_2 option:selected').html()
    

    $(document).ready(function() {
        $('select#select_2').change(function() {
            var selectedText = $(this).find('option:selected').text();
            alert(selectedText);
        });
    });
    

    小提琴


    Change your selector to

    val = j$("#select_2 option:selected").text();
    

    You're selecting the <select> instead of the <option>

    链接地址: http://www.djcxy.com/p/83112.html

    上一篇: jQuery通过其文本从selectbox中获取值

    下一篇: 使用jQuery获取所选选项的文本