At the moment I'm doing the following when the document is complete.
var passwordInputs = document.querySelectorAll("input[type=password]");
for (index = 0; index < passwordInputs.length; ++index) {
passwordInputs[index].addEventListener("focusin", activeWordsFocusIn);
passwordInputs[index].addEventListener("focusout", activeWordsFocusOut);
}
Which works as expected. However if the page has some additional script which modifies the DOM and adds more input
elements then they are not hooked.
How can add event handlers for ALL input
elements, even those added to the DOM thru script/ajax?
Not a duplicate I don't consider this a duplicate as this question Detect Changes in the DOM which focuses on detecting changes in the DOM. My questions focus is on adding an eventListener
to all input
elements even when the DOM changes. I have since added my own answer to this now.