Get selected value of a dropdown's item using jQuery

后端 未结 30 1528
广开言路
广开言路 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:20

    I know this is old but I though I update this with an more up to date answer

    $( document ).on( 'change', '#combo', function () {
    var prepMin= $("#combo option:selected").val();
     alert(prepMin);
    });
    

    I hope this helps

    0 讨论(0)
  • 2020-11-22 07:22

    try this

    $("#yourDropdown option:selected").text();
    
    0 讨论(0)
  • 2020-11-22 07:22

    The id that got generated for your drop down control in the html will be dynamic one. So use the complete id $('ct100_<Your control id>').val(). It will work.

    0 讨论(0)
  • 2020-11-22 07:23

    This is what works

        var value= $('option:selected', $('#dropDownId')).val();
    
    0 讨论(0)
  • 2020-11-22 07:24

    this will do the trick

    $('#dropDownId').val();
    
    0 讨论(0)
  • 2020-11-22 07:24

    Try this, it gets the value:

    $('select#myField').find('option:selected').val();

    0 讨论(0)
提交回复
热议问题