I am a newbie with jquery. I have a table as follows:
<td id="dropmenu">
<?php echo $user->first_name;?>
</td>
<td id="dropmenu" >
<?php echo $user->last_name; ?>
</td>
<td>
<?php echo $user->email; ?>
</td>
<td id="userid">
<?php echo $user->userid; ?>
</td>
In my js file, I have the following. I under #dropdown I add a edit and delete link. I need to get the userid from the row to put in the edit link like Edit. Everything works, but I cannot figure out how to get the userid number.
$(document).ready(function() {
$("#table-list-users tr td#dropmenu").hover(function(){
// get the value of the row id. This will be used in the edit href later on
var data = $(this).parent('td#userid').text();
console.log(data);
$(this).append('<div> <a href="/edit/data <-that will be the id">edit</a> | view | delete </div>') }, function(){
$(this).children("div").remove();
})
});