Show Buttons
Share On Facebook
Share On Twitter
Share On Google Plus
Share On Linkdin
Share On Reddit
Share On Stumbleupon
Contact us
Hide Buttons

querySelector vs getElementById

Get Ele­ment By Id

  • It returns a node list which is live, mean­ing if you add or remove any ele­ment from the DOM the node list will update
  • It is faster rel­a­tive to the query selec­tor methods

Query Selec­tor

  • It returns a node list which was avail­able at the time of the execution
Watch the fol­low­ing video see an exam­ple show­ing the dif­fer­ent between two methods.