jquery on click ID only works for first output

后端 未结 2 610
耶瑟儿~
耶瑟儿~ 2021-01-26 11:43

For a dashboard where there is a list of links I want to perform some actions if someone clicks the delete button. But somehow it only responds on the first link with id=\"delet

2条回答
  •  [愿得一人]
    2021-01-26 12:00

    In HTML Ids must be unique. If you have multiple elements, you should use classes.

    echo "";
    

    Script, Use class selector to bind event

    $('.delete_link').click(function(){
       //Your code will work fine
    });
    

提交回复
热议问题