jQuery id selector works only for the first element

后端 未结 7 2112
借酒劲吻你
借酒劲吻你 2020-11-22 02:55

I have 3 buttons with same id, I need to get each button value when he\'s being clicked.

7条回答
  •  庸人自扰
    2020-11-22 03:21

    ID means "Identifier" and is valid only once per document. Since your HTML is wrong at this point, some browsers pick the first, some the last occuring element with that ID.

    Change ids for names would be a good step.

    Then use $('button[name="xyz"]').click(function(){

提交回复
热议问题