jQuery id selector works only for the first element

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

    this also worked if you have multiple element with same id.

     $("button#xyz").click(function(){
      var xyz = $(this).val();
      alert(xyz);
     });
    

    you can check HERE

提交回复
热议问题