Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript, fastest way to remove a class from `<body>`

Tags:

People also ask

How do you clear a class in JavaScript?

To remove all classes from an element, set the element's className property to an empty string, e.g. box. className = '' . Setting the element's className property to an empty string empties the element's class list.

How do you remove a class from a div?

Use the classList. remove() method to remove a class from a div element, e.g. box. classList. remove('my-class') .


I have a body element on which I add a few classes. And I want to remove the no-javascript class from it, after it's being read by the browser.

   <body class="foo boo no-javascript bla">    <script type="javascript">       // remove no-javascript class here    </script>