Trung Vu Trung Vu - 25 days ago 4
jQuery Question

update data attribute value

I'm trying to update a data-id on Edit button, but for some reason it's stay on one id, which has taken it from first pick. Here is my code:


The reason it stays on one id is that you have this line in your function:

$(name + " .edit, " + name + " .delete").attr("data-id", id);

After your first click - you set the current it to all of the .edit and .delete elements in your document.

You can just remove this line and your code should work as you expected.