I am creating an element eltTooltip, s document.createElement, etc. and add it to the DOM like this ( idTooltipcontains idof eltTooltip):
document.body.appendChild(eltTooltip);
var addedElt = document.getElementById(idTooltip);
addedElt.addEventListener("click", function(){...});
Is the event clickguaranteed to be added here, or maybe the DOM is not ready for it?
Can I do it better? (The page has been loaded for a long time, so window.onloadit cannot be used. And I cannot use jQuery here.)
source
share