As far as I know document.getElementById ('myId') will only look for HTML elements that are already in the document. Let's say I created a new element through JS, but I have not added it to the document body yet, is there a way to access this element by its identifier, as usual, with getElementById?
var newElement = document.createElement('div');
newElement.id = 'myId';
var elmt = document.getElementById('myId');
Is there a workaround for this? (I have to say that I do not want to store links to this particular element, so I need to access it through its identifier)
Thanks!
user132539
source
share