I’m working on Twitch-API project ( http://codepen.io/raulfm/pen/ZeZVXR ). This function below is executed at page load. But I would like to execute this function again after click button event. I’ve tried, but it doesn’t work.
function listar(usernames, parent) {
var rows = parent.getElementsByClassName("row");
if(rows.length > 1) {
for(var i = 1; i < rows.length; i++) {
parent.removeChild(rows[i]);
}
}
for(var i = 0; i < usernames.length; i++) {
getLogo(usernames[i], parent);
}
}
I set the onclick property to function listar, but it didn’t work.
var allButton = document.getElementById("allbutton");
allButton.onclick = listar;
Why listar function doesn’t execute when I click on button?