DOM Manipulation

document.body

document.body

document.body is a direct reference to the page's body element. Use it when a state belongs to the whole page rather than one small component.

Custom data attributes are available through dataset. Setting document.body.dataset.mode writes a data-mode attribute on the body, which CSS or other scripts can read.

Your task: Mark the page as being in review mode by setting the body's data-mode value to review. Also add the is-reviewing class to the body.

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.

document.body

document.body is a direct reference to the page's body element. Use it when a state belongs to the whole page rather than one small component.

Custom data attributes are available through dataset. Setting document.body.dataset.mode writes a data-mode attribute on the body, which CSS or other scripts can read.

Your task: Mark the page as being in review mode by setting the body's data-mode value to review. Also add the is-reviewing class to the body.

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.