I have some inputs and a button. I want to implement function which allows to delete one of recently focused/focused out input.
I set onfocusout function which sets a click listener on button. If I focus on first input then focus out from it and click on button - works fine. But when I focus on first input, then on second and click on button - i get deleteCell() function performed n times i focused out.
How to let it remember only last onfocusout event? It seems to count my onfocusout events before clicking on button.
Thank you.
var input = document.createElement("input");
input.setAttribute("onfocusout", "myFunction()");
function myFunction() {
document.getElementById("delete-cell").addEventListener("click", function () {
deleteCell();
});
}
function deleteCell() {
alert(1);
}