jQuery get the selected dropdown value on change

后端 未结 6 1782
无人及你
无人及你 2021-01-17 17:51

I\'m trying to get the value of a dropdown on change (and then change the values in a second dropdown).

EDIT: Thanks for all the replies, i\'ve upda

6条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-17 18:12

    Check jQuery and Javascript methods here to get Single/ Multiple selected values in the Drop Down

    Demo Link

    jQuery Method: Method to get Selected Value from a select box:

    HTML

    
    
    
    

    jQuery

    $("#singleSelectValueDDjQuery").on("change",function(){
        //Getting Value
        var selValue = $("#singleSelectValueDDjQuery").val();
        //Setting Value
        $("#textFieldValueJQ").val(selValue);
    });
    

    Method to get Selected Value Option Text from a select box:

    HTML

    Select Value 0 Option value 8 Option value 5 Option value 4

    
    

    jQuery

    $("#singleSelectTextDDjQuery").on("change",function(){
        //Getting Value
        var selValue = $("#singleSelectTextDDjQuery :selected").text();
        //Setting Value
        $("#textFieldTextJQ").val(selValue);
    });
    

提交回复
热议问题