[英]Imageslider jQuery
Hi everyone (this is my first thread here) 大家好(这是我的第一个话题)
I'm making an "imageslider" (but with div:s) with jquery. 我正在用jquery制作“ imageslider”(但使用div:s)。 The question is, How do i hide my scrolling elements outside of the div with the border?
问题是,如何隐藏带有边框的div之外的滚动元素?
(I'm new here so i cant do post with links so i deleted them) The code: (我是新来的,所以我不能发布链接,所以我删除了它们)代码:
<script type="text/javascript">
var pos = 1;
$(document).ready(function(){
console.log("possition: " + pos);
var slides = $('#container .element');
var numberOfSlides = slides.length;
console.log("antal slides: " + numberOfSlides);
$('#right').click(function(){
if(pos<=numberOfSlides-1){
//$('#container div.element').animate({"left" : '+=200px' }, 1000, function() {pos++;});
$('#container div.element').animate({"left" : '+=200px' }, 1000 );
pos++;
console.log("possition: " + pos);
}
else{
$('#container div.element').animate({"left" : '-=400px' }, 1000);
pos=1;
console.log("possition: " + pos);
}
});
$('#left').click(function(){
if(pos>1){
$('#container div.element').animate({"left" : '-=200px' }, 1000);
pos--;
console.log("possition: " + pos);
}
else {
$('#container div.element').animate({"left" : '+=400px' }, 1000);
pos=3;
console.log("possition: " + pos);
}
});
});
</script>
<div id="container">
<div id="element1" class="element">3</div>
<div id="element2" class="element">2</div>
<div id="element3" class="element">1</div>
</div>
<link id="left" class="slideLink"><</link>
<link id="right" class="slideLink">></link>
easiest thing would be to use an existing plugin like this: 最简单的方法是使用现有的插件,如下所示:
http://www.gmarwaha.com/jquery/jcarousellite/ http://www.gmarwaha.com/jquery/jcarousellite/
Otherwise have you tried adding styling to your container div 否则,您是否尝试过将样式添加到容器div中
#container { overflow:hidden; }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.