Skip to content

Instantly share code, notes, and snippets.

@BlackSkorpio
Forked from mware/jquery.add-body-class.js
Created December 11, 2018 22:23
Show Gist options
  • Save BlackSkorpio/f8ea86d60154064da2e87fc5bbc5620e to your computer and use it in GitHub Desktop.
Save BlackSkorpio/f8ea86d60154064da2e87fc5bbc5620e to your computer and use it in GitHub Desktop.
add body class based on the url using RegEx
/* add body class */
var loc = window.location.pathname.match(/^\/?(\w+)\b/);
if(loc) $(document.body).addClass(loc[1].toLowerCase());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment