One jQuery Change Event on Multiple Elements

前端 未结 6 1397
醉酒成梦
醉酒成梦 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条回答
  •  孤城傲影
    2021-01-11 14:22

    Change all three elements with the #invent ID to a class instead (ID's must to be unique), or it's only going to work for the first element, like what's currently happening in your case.

    Then, you can target all of the elements that have the .invent class:

    $('input.invent').change(function () {
       // Here, $(this) refers to the specific element of the .invent class which 'changed'
    }):
    

    Read more about the difference between ID and Class selectors here.

提交回复
热议问题