Last active
April 24, 2016 16:24
-
-
Save michsch/769ce07b7ccb6aa8799175aa240acea1 to your computer and use it in GitHub Desktop.
Replace no-js class in HTML element
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html class="no-js" lang="de"> | |
<head> | |
<meta charset="utf-8"> | |
<title>JS class in HTML</title> | |
<meta name="description" content=""> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<link rel="stylesheet" href="css/main.css"> | |
<script> | |
!function(s,e){'use strict';s=document.getElementsByTagName('html')[0],e=s.className.split(' '),e.indexOf('no-js')>-1&&e.splice(e.indexOf('no-js'),1),-1===e.indexOf('js')&&e.push('js'),s.className=e.join(' ')}() | |
</script> | |
</head> | |
<body> | |
<h1>Writ <pre><code>js</code></pre> class.</h1> | |
</body> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
'use strict'; | |
var html, classes; | |
html = document.getElementsByTagName('html')[0]; | |
classes = html.className.split(' '); | |
if (classes.indexOf('no-js') > -1) { | |
classes.splice(classes.indexOf('no-js'), 1); | |
} | |
if (classes.indexOf('js') === -1) { | |
classes.push('js'); | |
} | |
html.className = classes.join(' '); | |
})(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!function(s,e){'use strict';s=document.getElementsByTagName('html')[0],e=s.className.split(' '),e.indexOf('no-js')>-1&&e.splice(e.indexOf('no-js'),1),-1===e.indexOf('js')&&e.push('js'),s.className=e.join(' ')}() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment