1
I need to create an element with Javascript that, when clicked, call a function.
Is there any event I can add to my code for that ? It would be equal to onclick()
that we put inside an html tag.
Follows the code
let inputExc = document.createElement('i') //cria
inputExc.className = 'fas fa-trash-alt ml-2' //define class
inputExc.title = 'Excluir' //define title
inputExc.id = 'iExcluir' //define id
How about the
onclick
?– Leandro Angelo
The onclick worked, thanks. But I had to call the function at the time I do the assignment, so: "inputExc.onclick = Function removerItem(){}"
– thiaguera94