0

我正在尝试创建一个 JQuery 插件来从右向左滑动一些图像。

我试图搜索一个插件,但我想我会自己创建它。
我有什么:
- 像这样的几个 DIV 元素:

<div class="footer_image_div project">
</div>
  • 我想如果我检索项目的所有位置并将它们动画到左侧 260 就可以了

我试过

$(function(){
         $('.project').each(function() {
             alert('a');
             var elm = $(this);
             elm.find(".project").animate({}, 500, function(){
                var pos = elm.find(".project").position();
                alert(pos.top);
             });

         });
      });

我也尝试过偏移,两者都返回NULL。

我该怎么办?我应该去哪里看?我很困惑

4

2 回答 2

0
$(function(){
     $('.project').each(function() {
         alert('a');
         var elm = $(this);
         elm.animate({}, 500, function(){
            var pos = elm.position();
            alert(pos.top);
         });

     });
  });
于 2012-05-08T09:00:05.647 回答
0
// This code will work right if `.project` is not nested.

.project {
    position: absolute;
}

$('.project').each(function() {
      var elm = $(this);
      elm.animate({
         left: '+=260px'
      }, 500, function(){
         var pos = elm.position();
      });
 });
于 2012-05-08T09:01:24.273 回答