Non-JQuery script class switcher

Categories: css, Javascript, Web Development

Tags: no-script, script

Been using the JQuery equivalent for some time. Just had the need to convert it, so thought I'd save it. It switches a 'no-script' class to a 'script' class on the HTML element and can be run in the head of the document.

var docElement = document.documentElement;
docElement.className = docElement.className.replace( /\bno-script\b/ , 'script');

2 Comments

Add a Comment