我有以下代码:
- $('ul.questions li a').click(function(event) {
- $('.tab').hide();
- $($(this).attr('href')).fadeIn('slow');
- event.preventDefault();
- window.location.hash = $(this).attr('href');
- });
这只是淡化一个div,基于什么时候点击,但我想让页面的URL哈希标签更改时,你点击,以便人们可以复制和加入书签。此时,当哈希标记更改时,这将有效地重新加载页面。
解决方法
这对我有用
- $('ul.questions li a').click(function(event) {
- event.preventDefault();
- $('.tab').hide();
- window.location.hash = this.hash;
- $($(this).attr('href')).fadeIn('slow');
- });
检查这里http://jsbin.com/edicu演示与几乎相同的代码