MCQs · Q5
Q.Which JavaScript method is commonly used to find a single element on a page by its unique id so the script can change it?
(A) document.write()
(B) document.getElementById()
(C) alert()
(D) console.log()
Maharashtra MsbshseTextbookSubjectiveImportance★★★★★est
42% · 5/12 Questions
You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.
Start your 14-day free trial to unlock the full solution →JavaScript changes a page through the DOM, first finding an element and then changing it.
(A) document.write() writes text into the document as it loads and can overwrite the whole page if used later — it does not select an element — incorrect.
(B) document.getElementById("id") returns the one element with that id so the script can read or change it (e.g. its innerHTML) — correct. …
Unlock everything free for 14 days
- Full step-by-step solutions
- Concept-first explanations
- Methods, shortcuts & mistakes
- PYQ mapping + timed mock tests
Full access for 14 days. No credit card required.