【问题标题】:jQuery div slide down when update更新时jQuery div向下滑动
【发布时间】:2013-03-06 06:34:32
【问题描述】:

我的代码在这里检查我的图像表上是否有新帖子。

当我有一个新帖子并且我的时间戳发生变化时,我想要一个 div 向下滑动,说有新的更新, 就像这张照片:

setInterval('checkForUpdates', 30000);
var lastTime = (new Date()).getTime();
function checkForUpdates() {
   $.get('image.php?timestamp=' . lastTime
      , function (results) {
         if (results) { /* fade into dom */ }
      }
   );
   lastTime = (new Date()).getTime();
}

【问题讨论】:

  • 你有什么问题?
  • 我的问题是当 jquery 检查我的 image.php 页面的时间戳时,我如何向下滑动一个 div!还有一个新的更新!

标签: jquery html refresh slidedown


【解决方案1】:

您是否尝试过使用滑下功能? http://api.jquery.com/slideDown/ 或从 0 jQuery animate height 为高度设置动画

【讨论】:

    【解决方案2】:
    //add the div with the new post text
    $("the conatiner id").prepend("<div class = 'new-post' style = 'width: 100%; height = 20px;'> A new post has been added </div>");
    //make it slide down
    $("the container id").find(".new-post:last").slideDown("fast");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-07-13
      • 1970-01-01
      • 2013-02-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-29
      相关资源
      最近更新 更多