← Quiz: DOM and Events: all 10 questions
Quiz: DOM and Events · Question 7 of 10
Which is the cleanest way to highlight a selected card from JavaScript?
Which is the cleanest way to highlight a selected card from JavaScript?
- A.Rewrite the card's innerHTML with inline styles
- B.card.classList.add("selected") and style .selected in CSS
- C.Delete and recreate the whole page
- D.Use document.write
Answer & explanation
Correct answer: card.classList.add("selected") and style .selected in CSS
Toggling classes keeps styling in CSS and behaviour in JavaScript.
Can you get the rest right without peeking?
Take the timed Quiz: DOM and Events quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →