Jquery 如果小于总高度,则添加到div边距
我试图建立一个滑块,将移动几个div上下点击。当我到达div的末尾时,我希望滑块停止。我真的很想看看我们是不是在最后一组 我绝对定位了div,幻灯片容器的高度是通过将所有这些加在一起计算出来的,然后我将使用边距上下移动幻灯片容器 在if语句中,如何比较边距顶部+下一个div高度将小于总高度(即,防止在一个方向上无限添加)Jquery 如果小于总高度,则添加到div边距,jquery,animation,slider,margin,Jquery,Animation,Slider,Margin,我试图建立一个滑块,将移动几个div上下点击。当我到达div的末尾时,我希望滑块停止。我真的很想看看我们是不是在最后一组 我绝对定位了div,幻灯片容器的高度是通过将所有这些加在一起计算出来的,然后我将使用边距上下移动幻灯片容器 在if语句中,如何比较边距顶部+下一个div高度将小于总高度(即,防止在一个方向上无限添加) if($('slide container').css({'marginTop':+=59}
if($('slide container').css({'marginTop':+=59}<$('slide container').height()){
//返回0
}
其中59是移动div的高度,所以我们在每次单击时都添加一个该值的边距。这个if语句应该检查我们是否在最后一个
谢谢,我想我找到了一个可行的解决方案。您需要导入jQuery UI才能运行它。您还需要编写上一个单击函数。但下面是下一个函数: 代码如下:
$(document).ready(function(){
var hideoptions = { "direction" : "up", "mode" : "hide"};
var showoptions = {"direction" : "down","mode" : "show"};
$('.webinar').not(':first-child').hide();
$('.webinar:first-child').addClass('active-slide');
$('span.next-arw').click(function(e){
if($('.active-slide').next().length>0){
console.log($('.active-slide').next());
var current=$('.active-slide');
var current_next=current.next();
current_next.addClass('active-slide');
current.removeClass('active-slide');
current.effect( "slide", hideoptions, 400);
current_next.effect( "slide", showoptions, 400);
}
});
});
希望这能帮上忙:)你能加把小提琴吗?当然可以:当然可以!感谢您喜欢并接受答案:)
$(document).ready(function(){
var hideoptions = { "direction" : "up", "mode" : "hide"};
var showoptions = {"direction" : "down","mode" : "show"};
$('.webinar').not(':first-child').hide();
$('.webinar:first-child').addClass('active-slide');
$('span.next-arw').click(function(e){
if($('.active-slide').next().length>0){
console.log($('.active-slide').next());
var current=$('.active-slide');
var current_next=current.next();
current_next.addClass('active-slide');
current.removeClass('active-slide');
current.effect( "slide", hideoptions, 400);
current_next.effect( "slide", showoptions, 400);
}
});
});