Now the most basic thing we need to do when we're creating our web sites is to select the elements in 1
our web page in order to manipulate it at a later date. 2
Now we saw that we can do this in Javascript by saying something like document.querySelector 3
and inside here we would add the selector that we want to select, 4
right? 5
So for example if we wanted the h1 then we can simply say querySelector("h1"). 6
Now if we were to write this in jQuery then we can remove all of this part and instead only have the 7
dollar sign which is short for jQuery. 8
So now we're using a jQuery method to select our h1, and you can see how much shorter it is. 9
Now this works very similarly to querySelector in the sense that inside the parentheses we're specifying 10
the CSS selector that we would use if we were to select our elements in CSS. 11
And this is because it's the most flexible, the most adaptable, and also can be very specific. 12
So for example it allows us to say things like we want the h1 that has a class of title, or we want 13
the h1 that's nested inside a div with the id of header. 14
And that works exactly the same. 15
There's no changes there. 16
But what the querySelector allows us to do is when we're trying to select all of our buttons, if you 17
remember from previously, we had to say something like document.querySelectorAll, and then we 18
would select the button in here. 19
Now, with jQuery, the dollar sign again replaces all of this and it will select all of the buttons 20
on screen and there's no difference between selecting one or selecting many.