Skip to content

Instantly share code, notes, and snippets.

@stephanie-walter
Created May 18, 2013 13:51
Show Gist options
  • Save stephanie-walter/5604464 to your computer and use it in GitHub Desktop.
Save stephanie-walter/5604464 to your computer and use it in GitHub Desktop.
Append class to an existing one in raw JS
document.body.className += ' hasJS'
@lovasoa
Copy link

lovasoa commented May 18, 2013

Awesome!

@lovasoa
Copy link

lovasoa commented May 18, 2013

The right way to do that on recent browsers is:

    document.body.classList.add('hasJS');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment