javascript - Add Class to element according to pathname -


this script works great adding class "criminal" div named "h1_wrapper" page:

if(window.location.pathname == '/criminal-law-blog') {$( ".h1_wrapper" ).addclass( "criminal" ); 

when click specific blog entry, adds pathname; example:

/criminal-law-blog/2014/11/criminal-law-blog-test-entry-1

how edit code make class added path follows "/criminal-law-blog"? know it's easy, can't figure out!

thanks in advance!

the simplest way window.location.pathname.match(/^\/criminal-law-blog/)


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -