亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

jQuery從不同頁面滾動到ID

jQuery從不同頁面滾動到ID

森林海 2019-09-21 11:21:03
我試圖在某些頁面中使用jQuery的頁面滾動,并且可以成功地進行平滑的頁面滾動。我現在唯一的問題是嘗試從其他頁面執行此操作。我的意思是,如果我單擊頁面中的鏈接,它將加載新頁面,然后滾動到特定的div元素。這是我用來在頁面內滾動的代碼:var jump=function(e){       //prevent the "normal" behaviour which would be a "hard" jump       e.preventDefault();   //Get the target   var target = $(this).attr("href");   //perform animated scrolling   $('html,body').animate(   {           //get top-position of target-element and set it as scroll target           scrollTop: $(target).offset().top   //scrolldelay: 2 seconds   },2000,function()   {           //attach the hash (#jumptarget) to the pageurl           location.hash = target;   });}$(document).ready(function(){       $('a[href*=#]').bind("click", jump);       return false;});我希望這個主意很清楚。謝謝非常重要的注意:我上面發布的這段代碼在同一頁面內也很好用,但是我要單擊的是單擊一個頁面上的鏈接,然后轉到另一頁面,然后滾動到目標。我希望現在已經清楚了。謝謝
查看完整描述

3 回答

  • 3 回答
  • 0 關注
  • 455 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號