在url中#-jquery/javascript之后查找姓氏
在jquery/javascript的url中,有没有一种方法可以获取#之后的姓氏 我想找到名字#价格 做一个假设陈述在url中#-jquery/javascript之后查找姓氏,javascript,jquery,Javascript,Jquery,在jquery/javascript的url中,有没有一种方法可以获取#之后的姓氏 我想找到名字#价格 做一个假设陈述 if( the_last_name == 'prices' ) // do something 我需要js/jquery找到一种获取URL姓氏的方法(并在if station/the_last_name上进行检查)使用以下方法: document.location.hash 例如: 更好的方法是使用以下命令: if (document.location.hash.subs
if( the_last_name == 'prices' )
// do something
我需要js/jquery找到一种获取URL姓氏的方法(并在if station/the_last_name上进行检查)使用以下方法:
document.location.hash
例如:
更好的方法是使用以下命令:
if (document.location.hash.substr(1) == "prices") {
因此字符串中没有“#”号。为什么不使用另一种方式,这样代码中就没有.substr(1)
?1个额外字符对10个。
if (document.location.hash.substr(1) == "prices") {