簡體   English   中英

JS頁面滾動不起作用

[英]JS page scroll didn't work

我寫了類似的代碼

$.ajax({
  type: 'POST',
  url: form.attr('action'),
  data: data,
  dataType: 'html',
  success: function(html){
    $(html).hide().appendTo(parent.find("[data-interactions]")).show().stop().animate({
        scrollTop: $(".vote_feedback_snippet:last-child").offset().top
    }, 1500,'easeInOutExpo');

當我單擊發布按鈕時,上面的代碼在列表的底部生成了新的HTML代碼段。 我想要的是:-當出現新的HTML代碼段時,它只會滾動到該代碼段

有人可以幫我嗎

嘗試:

$(html).hide()
.appendTo(parent.find("[data-interactions]"))
.show('fast', function(){
  $('html, body').animate({
     scrollTop:  $(".vote_feedback_snippet:last-child").offset().top
  });
});

使用此插件: http : //demos.flesler.com/jquery/scrollTo/

將允許您執行以下操作:

$.scrollTo(".vote_feedback_snippet:last-child")

它一直為我工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM