Categories
blog js

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());

 

https://gist.github.com/mware/4118884