javascript - How to add body class to front page & an internal page using jQuery? -


the jquery function below works properly, , adds full class <body> html element on /signin/ page based on url.

// add full class sign in page body based on url  $(function() {     var loc = window.location.href; // returns full url     if(/signin/.test(loc)) {     $('body').addclass('full');   } }); 

i want accomplish exact same thing on front/home page, or / url within same function. how do this?

regexes slow. faster way:

function() {     var loc = window.location.pathname; // returns pathname     if(loc == '' || loc == '/') {         $('body').addclass('full');     } }); 

Comments