Skip to content

Instantly share code, notes, and snippets.

@jeffdrumgod
Created October 20, 2020 19:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffdrumgod/c4f2d8c26b2422a134e7349d96544399 to your computer and use it in GitHub Desktop.
Save jeffdrumgod/c4f2d8c26b2422a134e7349d96544399 to your computer and use it in GitHub Desktop.
hash-change-class-body-vtex-checkout.js
(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