Hello, I have a question:
I create a div, but my “platform” after executes the javascript, it creates a general div for all the elements that have been created using javascript. And it sets by default width and height(400, 200).
My div has 400 width, but I need auto height because I need to expand it automatically if I add new elements.
You can get the parent node via the property of that name:
document.getElementById('upholder').parentNode.style.height = 'auto'
// Or just remove the height inline style to fall back to the CSS:
document.getElementById('upholder').parentNode.style.height = ''
But if that div gets created dynamically with JS it may not be available from the start, so you’ll have to find a way to wait for that element to be appended to the document.
No, not really… getElementById() is slightly faster, but that shouldn’t matter in any real-world application. Personally I just like to use getElementById() to express more clearly when I’m interested in that unique element, rather than the first element that happens to match the selector.
LOL but no I think you’re confusing this with the quantumSelector(), which simultaneously both does and does not find a match until its result gets accessed. :-P