Dominique Ari2,721 Points
Would it not be better to use classList.add?
wouldn't it be better to use these instead? In practice you wouldn't normally want to overwrite all existing classes. event.target.classList.add('highlight'); event.target.classList.remove('highlight');
Robert ManolisTreehouse Guest Teacher
Hi Dominique Ari, you're absolutely correct. While setting a
className with a simple assignment operator,
=, is something to be aware of, the safer approach is to use the
classList property along with its
toggle() methods, as you mentioned, and for the very reason you mentioned.