🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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?

  1. A.Rewrite the card's innerHTML with inline styles
  2. B.card.classList.add("selected") and style .selected in CSS
  3. C.Delete and recreate the whole page
  4. 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 →