Add multiple classes with classlist add

Asked by: tomlance79
Date:
Viewed: 230
Answers: 1
  • 0

Hi,

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');

Answers

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!