Why don't we just use element IDs as identifiers in JavaScript?
HTML 5 spec, 'Named access on window object"
window[name]
Returns the indicated element or collection of elements.
As a general rule, relying on this will lead to brittle code. Which IDs end up mapping to this API can vary over time, as new features are added to the web platform, for example. Instead of this, use document.getElementById()
or document.querySelector()
.
'✘✘✘ Web' 카테고리의 다른 글
[Javascript][Regex] Regex test does not select all items from a list (0) | 2022.08.22 |
---|---|
Editable Dom => attribute: contentEditable (0) | 2022.07.22 |
the-dom-challenge: Build something with only vanilla Javascript (0) | 2022.07.22 |
[axios] onUploadProgress - progress bar (0) | 2022.07.07 |
[chrome][devtools] elements tab right click not working (0) | 2022.07.07 |
댓글