jQuery dropdown select event

前端 未结 1 1121
梦毁少年i
梦毁少年i 2021-01-27 17:21

Is there a specific event for when a user selects an item in a dropdown box? I am creating a fairly large form that uses multiple dropdown boxes. On load all but the first are d

1条回答
  •  执念已碎
    2021-01-27 18:20

    Try Below code:

    
    
    

    Jquery

    $(document).ready(function(){
    $("#drop2").attr("disabled", true);
    $("#drop1").change(function(){
        $("#drop2").attr("disabled", false);
        //Put your ajax code here and bind like below code
        $("#drop2").append(new Option("option text", "value"));
        $("#drop2").append(new Option("xxx","1"));        
    });
    });
    

    Demo: http://jsfiddle.net/J5kmz/

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