DOM Manipulation

classList.add

classList.add

classList is the DOM API for working with an element's classes. classList.add adds one class without replacing the others.

That is safer than assigning the whole className string when the element already has layout, theme, or state classes you need to keep.

Your task: Select the current step and add the is-current class to it. Keep its existing step class.

Free with a JS Exercises account

Sign in to start coding, run your solution, and keep your progress saved for later. No payment needed.

By continuing, you agree to our Terms and Privacy Policy. We'll send occasional product updates and news. You can unsubscribe anytime.

classList.add

classList is the DOM API for working with an element's classes. classList.add adds one class without replacing the others.

That is safer than assigning the whole className string when the element already has layout, theme, or state classes you need to keep.

Your task: Select the current step and add the is-current class to it. Keep its existing step class.

Free with a JS Exercises account

Sign in to start coding, run your solution, and keep your progress saved for later. No payment needed.

By continuing, you agree to our Terms and Privacy Policy. We'll send occasional product updates and news. You can unsubscribe anytime.

Console

Run code to see output.