I am filling a table as follows:
$.ajax({
method: "GET",
url: "https://api.github.com/search/users",
data: { q: search, sort: "repositories" }
})
.done(function( msg ) {
jQuery.each(msg.items, function(i, users){
getRepositories(users.repos_url).done(function (result) {
var repositories = result.length;
$( 'tbody' ).append('<tr class="user"><td><a class="username">' + users.login + '</a></td><td>' + repositories + '</td>');
});
});
});
I just need to get the value inside the <a class="username">
element when the user clicks.
What I've already tried:
$( ".user .username" ).click( function() {
console.log($( this ).text());
});
E:
$( ".user" ).click( function() {
console.log($( this ).children('a').text());
});
And it does not just show anything on the console, nor a undefined
. = (