我有一个哈希替换了jQuery来处理我的手风琴。
var hash = window.location.hash;
var _hash = hash.replace(/#/, '');
但是,我的导航中还有一个哈希链接(/ hello#let-us)滚动到id = let-us的div。如何更改上面的jQuery来过滤哈希替换(替换除'/ hello#let-us'之外的所有哈希链接)?
答案 0 :(得分:0)
只需检查_hash
的结果...如果使用了jQuery,那么http://api.jquery.com/jquery.inarray/
var toCheck = ['let-us', 'another-value'];
if ($.inArray(_hash, toCheck) == -1) {
// hash is not in array toCheck
}