Get selected value of a dropdown's item using jQuery

后端 未结 30 2007
广开言路
广开言路 2020-11-22 06:48

How can I get the selected value of a dropdown box using jQuery?
I tried using

var value = $(\'#dropDownId\').val();

and



        
30条回答
  •  天涯浪人
    2020-11-22 07:13

    You can use any of these:

    $(document).on('change', 'select#dropDownId', function(){
    
                var value = $('select#dropDownId option:selected').text();
    
                //OR
    
                var value = $(this).val();
    
    });
    

提交回复
热议问题