Dynamically select Drop Down in Jquery

前端 未结 4 992
遇见更好的自我
遇见更好的自我 2021-01-29 09:16

I have 4 Drop Downs.

Each drop by default has a --select-- option. Each box has a unique id. As you can see, the second drop down is disabled if the above drop

4条回答
  •  不要未来只要你来
    2021-01-29 09:43

    Check this one;

    HTML code:

    
    
    
    
    

    JS Code:

    $(document).ready(function(){
    
         $("[id^=sel]").change(function(){
    
               /*
               *  find out the current box id
               */
    
               var id=$(this).attr("id");
               /*
               *  find out the current box id order number
               */
    
               var ordernumber=id.split("-")[1];
    
               if($(this).val()!="select")
               {
                     //enable next one
                     $("#sel-"+(ordernumber+1)).show();
               }
         })
    })
    

提交回复
热议问题