我创建了jQuery滑块,当我单击下一个箭头时,它将滑动下一个图像。现在我需要持续显示它(即)如果达到滑块中的最后一个图像。然后,第一张图片应从右侧滚动。为此,我试着jquery追加。它正在追加。但是,当我打印位置时,它显示旧位置,而不是附加位置。在jQuery中连续滚动div
<div id="parent">
<div class="child">
</div>
<div class="child">
</div>
<div class="child">
</div>
<div class="child">
</div>
</div>
(i.e)//jQuery
numberOfSlides = 4; //Total no of images
$('arrow').click(function(){
if(currentSlide == 2) //if i am in the second slide, then append first slide to the last slide
{
$('first-child').append('parent'); // This code is for reference. not in correct syntax.
}
else
{
for()//loop
{
//sliding all images to the left (i.e)if the image width is 800px. then the slide animation will be -800,0,800,1600 for(slide1,slide2,slide3,slide4).so that second image will show now.
$('.child:nth-child('+loop_count+')').animate({'marginLeft','xxpx'});
}
}
currentSlide++;
});
正确O/P时currentSlide 2是-800,0,800,1600为(滑件,滑件3,slide4,滑件1) 在如果条件将追加到父元素的第一个元素上面的代码。但是当我得到附加元素的位置时,它会打印一些-1600像素(当我检查萤火虫时,它显示右侧的div)。但它应该是1600px;我正在使用marginLeft进行定位。
感谢