Be the first user to complete this post

  • 0
Add to List

querySelector vs getElementById

Get Element By Id

  • It returns a node list which is live, meaning if you add or remove any element from the DOM the node list will update
  • It is faster relative to the query selector methods

Query Selector

  • It returns a node list which was available at the time of the execution
Watch the following video see an example showing the different between two methods.
[youtube https://youtu.be/6Y2T5P5BsfU?t=3m2s]



Also Read:

  1. Array filterUntil function implementation for javascript
  2. A simple requestAnimationFrame example visually explained
  3. gzip compress and cache api response in express
  4. Split a string in javascript when both comma and spaces are present
  5. css : center element vertically and horizontally
  6. css - circular profile pictures
  7. Testing promise sequence using mocha, chai, chai-as-promised, sinon