admin管理员组

文章数量:1322850

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 badges
Add a ment  | 

2 Answers 2

Reset to default 8

Use 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.

本文标签: find last names in url after jquery javascriptStack Overflow