Share
💥
querySelector 없이 id를 가진 객체에 접근하기 - window global variables
라는 div element가 HTML 트리 어딘가에있다고 가정하자.
element에 접근하기 위해서는
window.querySelector("#foo")
와
window.getElementById(”foo”)
를 쓰는것이 보편적일것이다.
하지만,
window.foo
를 사용해도 동일한 결과를 얻을 수 있다.
HTML Standard
Accessing Element IDs in DOM as window/global variables
During my early web development days, element IDs was one of the first things I learned on how to manipulate elements from JS land. With…