繁体   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