I am creating a form from javascript. I have to put the onclick on the a tag to call a method when clicked. I am doing like this, but it is not appearing the onclick.
function remPass() {
var log = document.getElementById("login");
var form = document.createElement('form');
form.method = "post";
form.action = "";
log.appendChild(form);
var input = document.createElement('input');
input.type = "text";
input.name = "username";
input.className = "username";
input.placeholder = "Usuario";
var a = document.createElement('a');
a.className = "bt-enter pink";
a.id = "recordar";
a.href = "#";
a.onclick = "remember()"; //Here is the problem
a.innerHTML = "Recordar contraseña";
form.appendChild(input);
form.appendChild(a);
}