[英]JQuery Animate .offset() .position() returns NULL
I am trying to create a JQuery plug in to slide some images from right to left. 我正在尝试创建一个JQuery插件,以从右向左滑动一些图像。
I tried to search for a plug in but i thought i'd create it myself. 我试图搜索一个插件,但我想自己创建一个。
What I have: 我有的:
- several DIV elements like this: -几个像这样的DIV元素:
<div class="footer_image_div project">
</div>
I tried 我试过了
$(function(){
$('.project').each(function() {
alert('a');
var elm = $(this);
elm.find(".project").animate({}, 500, function(){
var pos = elm.find(".project").position();
alert(pos.top);
});
});
});
I did try offset aswell both do return NULL. 我也尝试过偏移量,并且都返回NULL。
What should i do? 我该怎么办? Where should i look? 我应该在哪里看? I am confused 我很困惑
$(function(){
$('.project').each(function() {
alert('a');
var elm = $(this);
elm.animate({}, 500, function(){
var pos = elm.position();
alert(pos.top);
});
});
});
// 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();
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.