I create dynamic content via jQuery that looks like:
$('#usersList tbody').append(' \
<tr id="user_4242" class="highlight-tr"> \
<td class="users-list-name">Dan</td> \
<td class="users-list-edit" data-userid="{{ $user->id }}" data-toggle="modal" data-target="#userEditModal"> \
<button class="btn btn-default btn-sm edit-user-btn"><i class="glyphicon glyphicon-edit"></i> Edit</button> \
</td> \
</tr> \
');
Then, I try accessing the content in ".users-list-name"
with:
$('.users-list-edit', '#usersList').on('click', function () {
var name = $(this).parent().find('.users-list-name').text();
console.log(name) // dynamic content not working here
});
#usersList
is the id of the table.
That click function works for the data that was already there on page load.
How can I access data in this dynamic appended content?