One jQuery Change Event on Multiple Elements

前端 未结 6 1387
醉酒成梦
醉酒成梦 2021-01-11 13:46

I have 3 textboxes, all with the same id\'s that I process into ASP by bringing it into a controller array

I have a link that adds an unlimited number of textboxes b

6条回答
  •  旧时难觅i
    2021-01-11 13:59

    Lets say your HTML is like this:

    
    
    
    
    
    
    

    Now the Id must be unique. So put a class to all the inputs like invent and the HTML will be:

    
    
    
    
    
    
    

    And call the on change event like:

    // This would be called now for all the text-boxes
    $('input.invent').change(function () {
       // Your code here
    }):
    

    In case, you can't add class for all the text-boxes. You cam simply do this:

    $("input:text").change(function () {
       // Your code here
    }):
    

提交回复
热议问题