Created
October 20, 2020 19:15
-
-
Save jeffdrumgod/c4f2d8c26b2422a134e7349d96544399 to your computer and use it in GitHub Desktop.
hash-change-class-body-vtex-checkout.js
This file contains 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() { | |
var onhashChange = function() { | |
var step = window.location.hash.replace(/\W/g,''); | |
for(var item in document.body.classList) { | |
if ({}.hasOwnProperty.call(document.body.classList, item)) { | |
if (document.body.classList[item].indexOf('step-now-') === 0) { | |
document.body.classList.remove(document.body.classList[item]); | |
} | |
} | |
} | |
document.body.classList.add('step-now-'+ step); | |
} | |
window.addEventListener('hashchange', onhashChange); | |
onhashChange(); | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment