Content comes from DB. I go foreach on array and insert rows into table. This is the structure of 1 row:
<tr>
<td data-name = '<?php echo $name ?>'><?php echo $name ?></td>
<td data-email = '<?php echo $email ?>'><?php echo $email ?></td>
<td><form method='post'><button class='delete' name='delete' ...>Remove</button></form></td>
<tr>
I am trying to get the content of each data attribute in a row:
$('.delete').click(function (e) {
e.preventDefault();
let name = $(this).parents('tr:first').find('td').data('name');
let email = $(this).parents('tr:first').find('td').data('email'); // <--- undefined
if (confirm(name + ' ' + email + ' delete?')) {
...code goes futher...
The question is: I get name value, but email is undefined. What is wrong? I also see the value of email variable in the table and in data attr in dev Console