querySelector()method returns the first element that matches a specified CSS selector in the document. In order to return all the matches, use
So why people include jQuery only for use
First of all, jQuery works for older browsers like IE6-7 that doesn't support CSS 2.1 - 3.0 selectors.
jQuery offers you more advanced selectors like pseudo-class (i.e
:selected) and more complex syntax (i.e
But of course if you think you can rely on simple selectors (classes, ids), jQuery is probably too much for you.
Also you can check performance for those two selectors: jquery-vs-native-selector-and-element-style
See also: Browser support for query selector