Get value of select option immediately jquery

后端 未结 4 1587
暗喜
暗喜 2021-01-29 02:16

I have a simple dropdown and want to get the specific value of an option if the user changes the dropdown selection, but without having him to push a submit button. Is this poss

相关标签:
4条回答
  • 2021-01-29 02:43

    its very simple.. try this

    $('#BezirksAuswahl').change(function(){
            var selected_value = $(this).val();
    });
    
    0 讨论(0)
  • 2021-01-29 02:47

    Check your JQuery include, you must not be including Jquery correctly. What version are you referencing?

    Ensure you are running your script when JQuery is loaded:

    $(document).ready(function () {
      $('#BezirksAuswahl').change(function(e){
         alert(this.value);
      });
    });
    
    0 讨论(0)
  • 2021-01-29 02:50
    $('#BezirksAuswahl').change(function(){
             alert($(this).val());
    });
    
    0 讨论(0)
  • 2021-01-29 02:53

    Use the change event, which fires when the value of the element changes, like so:

    $('#BezirksAuswahl').change(function(e){
        alert(this.value);
    });
    
    0 讨论(0)
提交回复
热议问题