var btn = document.createElement('input'); btn.type = "button"; btn.className = "btn"; btn.value = entry.email; btn.onclick = (function(entry) {return function() {chooseUser(entry);}})(entry); td.appendChild(btn);