if I have html that integrated on php like this :
foreach ($data_pc as $data) {
?>
<tr>
<td class="center"><?php echo $no++ . ". "; ?> </td>
<td class="center" data-no="<?php echo $data['id_pc'] ?>"><?php echo $data['nama_user']; ?></td>
<td class="center"><?php echo $data['perusahaan']; ?></td>
<td class="left">
<a class="btn btn-info" name="edit" title="Edit User" req_id="<?php echo $data['nama_user']; ?>" data-toggle="modal" data-target="#myModal1" role="button">
<i class="halflings-icon white edit"></i>
</a>
<td>
<a class="btn btn-danger" id="btn-hapus" title="Hapus User" req_nama="<?php echo $data['nama']; ?>">
<i class="halflings-icon white trash" ></i>
</a>
</td>
</td>
</tr>
<?php } ?>
that would be representated row on table html.
I want to take the attribute data-no
on a row.
So, I write jquery code like this :
$(document).on('click', '#btn-hapus', function() {
var $row = $(this).closest("tr"); // Find row
var data = $row.find("data-no").text(); // Find text
alert(data);
});
It gives me a blank value ? How to find attribute on a row table using jquery ?