I need to add a new event listener to a dynamically created element and I cannot get the listener to attach.
I attempted this method with no success: add event listener on elements created dynamically
b[0] = document.createElement("INPUT");
b[0].name = "dt";
b[0].type = "text";
b[0].value = "YYYY-MM-DD HH:MM:SS";
b[0].addEventListener('focus', removeVal);
b[0].addEventListener('blur', addDTFormat);
b[0].className = "fields";
Below is the screenshot from Chrome dev tools. I have the add listener method with the correct parameters, but in the properties pane the onblur
and onfocus
events are null for this element.