Which is better – getElementById or querySelector? Well, better is a very subjective answer. Both getElementById and querySelector are an element-grabbing method from the JavaScript Document Object Model (DOM), so with each method, you can pick up whatever element you want to manipulate with, of course depending on the circumstances. The advantage at least is that you don’t have to choose which one you’ll use – both, GetElementById and querySelector method have their own use cases and you can choose methods interchangeably. However, the question remains – why use one over the other? So, let’s dive in.