jQuery id selector works only for the first element

后端 未结 7 2001
借酒劲吻你
借酒劲吻你 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:14

    You can't have the same id because id is unique in page HTML. Change it to class or other attribute name.

    $('attributename').click(function(){ alert($(this).attr(attributename))});
    

提交回复
热议问题