The querySelector() method returns the first element that matches a specified CSS selector (such as ID, class name, or type) in a document. If multiple elements have the same selector, then only the first one is returned.
Consider the following code snippet, which demonstrates the usage of the querySelector() method:
Free Resources