What is the purpose of the "querySelector()" method in JavaScript?
-
A
Selecting the first HTML element that matches a CSS selector
Correct answer
-
B
Modifying the CSS styles of all elements on a page
-
C
Creating new HTML elements
-
D
Accessing the entire HTML document
Correct answer
A. Selecting the first HTML element that matches a CSS selector
16 views
Explanation
"querySelector()" allows selecting the first HTML element that matches a specified CSS selector, facilitating flexible DOM manipulation.
Video explanation
Doubts & discussion
Not sure why the answer is A? Ask here and get an explanation.
Ask a doubt about this MCQ