Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 我需要修改我的jquery滚动到锚定代码,这样它也会滚动到新页面上的achnor_Javascript_Jquery_Html - Fatal编程技术网

Javascript 我需要修改我的jquery滚动到锚定代码,这样它也会滚动到新页面上的achnor

Javascript 我需要修改我的jquery滚动到锚定代码,这样它也会滚动到新页面上的achnor,javascript,jquery,html,Javascript,Jquery,Html,我是jQuery新手,我有一段代码可以很好地平滑地滚动到页面锚。但我也需要从另一个页面开始工作。我能对下面的代码做些什么吗 示例:在第1页中,单击指向第2页下方一半的锚的链接。我希望浏览器跳转到第2页的顶部,然后向下滚动到锚点。我想不出用这个代码怎么做 <script type="text/javascript" src="jquery.easing.1.3.js"></script> <script type="text/javascript"> $(fun

我是jQuery新手,我有一段代码可以很好地平滑地滚动到页面锚。但我也需要从另一个页面开始工作。我能对下面的代码做些什么吗

示例:在第1页中,单击指向第2页下方一半的锚的链接。我希望浏览器跳转到第2页的顶部,然后向下滚动到锚点。我想不出用这个代码怎么做

<script type="text/javascript" src="jquery.easing.1.3.js"></script>
<script type="text/javascript">
$(function() {
                $('ul.nav a').bind('click',function(event){
                    var $anchor = $(this);               
                    $('html, body').stop().animate({
                        scrollTop: $($anchor.attr('href')).offset().top
                    }, 2400,'easeInOutExpo');

                    event.preventDefault();
                });
            });


            $(document).scroll(function(){
        t = (100 - $(this).scrollTop())/100;
        if(t<0)t=0;
        $('.skyB').css({opacity: t})
    })

</script>

$(函数(){
$('ul.nav a').bind('click',函数(事件){
var$anchor=$(此);
$('html,body').stop().animate({
scrollTop:$($anchor.attr('href')).offset().top
},2400,“easeInOutExpo”);
event.preventDefault();
});
});
$(文档)。滚动(函数(){
t=(100-$(this.scrollTop())/100;

if(t使用
location.hash
提取哈希ID并重新使用事件处理程序

$(function() {
    var id = location.hash; // includes the leading #
    $('ul.nav a[href$="'+id+'"]').click();
    // continue as before

感谢您的回复。我一定是做错了什么,因为这似乎也不起作用:请参阅修订后的发布代码。如果您能提供任何帮助,我们将不胜感激。谢谢您的时间。
$(function() {
    var id = location.hash; // includes the leading #
    $('ul.nav a[href$="'+id+'"]').click();
    // continue as before