Add multiple classes with classlist add

Asked by: tomlance79
Viewed: 314
Answers: 1
  • 0


Is there a way to add more than one class with the classlist.add method?

This one doesn’t work for me:

btn.classList.add('btn btn-lg');


Answer by: jenniryan

Answered on: 21 Jul 2023

  • 0

You should use it like this:

btn.classList.add('btn', 'btn-lg');

Please log in to post an answer!