I am trying to apply some javaScript on an element that initially has a display:none attribute. Example:
<input type="button" onclick="document.getElementById('container').style.display='block';">
<div style="display:none;" id="container">
<input type="text" name="somename" id="somename" onclick="applySomeJsToTextField();">
</div>
function applySomeJsToTextField() {
//js code here
}
Since the element is not visible to the DOM of loaded as or within a display:none element, how can I change this?
Thanks
The fact that the element has the
displayproperty set to something means that the element is in the DOM.You can apply some JS to hidden elements, they’re still elements loaded in the DOM.