1. Home
  2. Computer Science MCQs
  3. Javascript
  4. What is the purpose of the "querySelector()" method in…

Added 28 Jan 2024

What is the purpose of the "querySelector()" method in JavaScript?

  1. Selecting the first HTML element that matches a CSS selector Correct answer
  2. Modifying the CSS styles of all elements on a page
  3. Creating new HTML elements
  4. Accessing the entire HTML document

Correct answer

A. Selecting the first HTML element that matches a CSS selector

16 views

MCQSEXAM

Explanation

"querySelector()" allows selecting the first HTML element that matches a specified CSS selector, facilitating flexible DOM manipulation.

Video explanation

Reference

https://www.w3schools.com/js/default.asp

Doubts & discussion

Not sure why the answer is A? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More Javascript MCQs

Practise all Javascript MCQs

Similar MCQs