我有这样的代码:
$(e).click(function() {
    console.log(this.href);
    location.hash = this.href;
});
这e是一个<li>像这样的元素:<li href="#about">About</li>
location.hash有 onchange 监听器:
$(window).hashchange(function() {
    if (location.hash=="") location.hash="me";
    $(".content").spin();
    $(".content").load("http://example.com/inc/"+location.hash.substr(1), function() {
        $(this).spin(false);
    });
});
UPD:问题不在于变量访问,因为 console.log 打印变量的正确值。