javascript - Why does getElementById not work on elements inside the document element? -


this question has answer here:

if use getelementbyid document - document.getelementbyid works.

but however, if perform same on element x x.getelementbyid, returns error.

the unusual thing getelementsbyclassname , getelementsbytagname work on elements getelementbyid doesn't!

container ids should unique, there's no reason find object id within container. why need document.getelementbyid access element id, whereas when searching class or tag name, might want search within specific container, why can x.getelementsbyclassname etc.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -