getting a data id from button click event with on()
I have had to amend some code to grab a data-id from a button click as the button click event now uses on() due to copies of the same button being added dynamically so I now have:
- $(document).on("click", ".like", function (evt) {
- evt.preventDefault();
- LikeComment($(this).data("cid"));
- });
My problem with this is that $(this).data("cid") is now undefined.
How can I get at this using the new code above?