The HTML document.querySelector() method

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:

  • HTML

Free Resources

Copyright ©2024 Educative, Inc. All rights reserved