【发布时间】:2013-02-08 05:55:29
【问题描述】:
当我尝试这样做时:
if (window.location.hash) {
current_page = window.location.hash;
}
$(current_page).siblings('.page').css(display: 'none');
current_page 将是例如 #hello,所以我认为没有必要删除 #,因为我使用 ID 来识别元素。
这是我在 chrome 中的错误:Uncaught SyntaxError: Unexpected token:
我没有得到更多。
我在这里阅读了有关如何在选择器中使用变量的其他问题,它应该可以工作。我还重写了两次以确保没有隐藏字符。
有谁知道怎么回事?
【问题讨论】:
-
window.location.hash 中有什么? ->
console.log(window.location.hash)
标签: jquery variables jquery-selectors