javascript - Why does getElementById not work on elements inside the document element? -
this question has answer here:
- chaining getelementbyid 5 answers
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
Post a Comment