在尝试使用hashchange并找出它在Internet Explorer中无法正常工作后,我决定尝试使用click()方法。下面应该做的是当点击链接时,检查url是否包含页面,然后将link_content的html更改为div内容,其id等于散列。为什么.on()不适用于未预加载在页面上的链接?
它适用于所有预加载页面的链接,但link_content div中的当前链接不会触发。为什么这不起作用?
$(document).ready(function() {
$('a').on("click", function(event){
if (location.pathname.search("boh.html")){
hash=this.hash;
if(hash=='#more'){
$('#link_content').html($('#hiddenlist').html());
}
else if(hash){
$('#link_content').html($(hash).html());
}
}
});
});
完美伊恩。谢谢。 – alrightgame 2013-02-15 17:05:21