最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

find last names in url after # - jquery javascript - Stack Overflow

programmeradmin2浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论