Find last names in url after # - jquery / javascript

Is there a way to get the last names after the # in the url in jquery / javascript

I want to find the names #prices and do an if if

if( the_last_name == 'prices' ) 
// do something


I need js / jquery to find a way to get the name of the last url (and check it against if stat / the_last_name)


source to share

2 answers

Use this:




if (document.location.hash == "#prices") {




Better, use this:

if (document.location.hash.substr(1) == "prices") {


so that you don't have "#" in your line.



All Articles