Web development · The DOM and events

The page is a tree

Every script that changes a page works on the same thing: the tree the browser builds from your HTML, not the file itself.