dav*_*ern 52 hash jquery reload window.location fragment-identifier
我有以下代码:
$('ul.questions li a').click(function(event) {
$('.tab').hide();
$($(this).attr('href')).fadeIn('slow');
event.preventDefault();
window.location.hash = $(this).attr('href');
});
Run Code Online (Sandbox Code Playgroud)
这简单地根据您点击的时间淡化div,但我希望您点击时更改页面URL哈希标记,以便人们可以复制和添加书签.目前,当哈希标签发生变化时,这会有效地重新加载页面.
是否可以更改哈希标记而不重新加载页面以防止跳跃效应?
jit*_*ter 79
这适合我
$('ul.questions li a').click(function(event) {
event.preventDefault();
$('.tab').hide();
window.location.hash = this.hash;
$($(this).attr('href')).fadeIn('slow');
});
Run Code Online (Sandbox Code Playgroud)
点击http://jsbin.com/edicu查看几乎相同代码的演示
归档时间: |
|
查看次数: |
102567 次 |
最近记录: |