Is there a way to get the last names after # in the url in jquery/ javascript
I want to find the names #prices and make an if statment
if( the_last_name == 'prices' )
// do something
I need js/jquery to find a way to get urls last name ( and check it on the if statment /the_last_name)
Is there a way to get the last names after # in the url in jquery/ javascript
I want to find the names #prices and make an if statment
if( the_last_name == 'prices' )
// do something
I need js/jquery to find a way to get urls last name ( and check it on the if statment /the_last_name)
Share Improve this question asked Aug 30, 2009 at 13:21 williamwilliam 6063 gold badges14 silver badges29 bronze badges2 Answers
Reset to default 8Use this:
document.location.hash
eg:
if (document.location.hash == "#prices") {
Better, use this:
if (document.location.hash.substr(1) == "prices") {
so you don't have the '#' in your string.