【发布时间】:2011-10-19 06:38:31
【问题描述】:
我有一个包含三个 <section> 元素的轮播。像这样:
<div role="main" class="main selection-carousel">
<section>
<h1>Kies je <span class="right">favoriete</span> Smaak</h1>
<aside class="aside">
</aside>
</section>
<section>
<h1>Item 2</h1>
<aside class="aside">
</aside>
</section>
<section>
<h1>Item 3</h1>
<aside class="aside">
</aside>
</section>
<img src="static/img/bg-selection-carousel.png" width="2610" height="600" alt="" class="carousel-image">
<a href="#" title="Ga naar de volgende thee smaak" class="carousel-left">Ga naar de volgende thee smaak</a>
<a href="#" title="Ga naar de vorige thee smaak" class="carousel-right">Ga naar de vorige thee smaak</a>
</div>
当您单击<a> .carousel-left 时。 <img> 向左移动 -1000 像素。第二部分是展示。当你点击 carousel-right 时。图像向右移动 1000 像素。之前的部分是展示。
但是我的轮播按钮有问题。当我在第一部分时。然后你不能右键单击轮播。我该怎么做呢?
当我在第一部分时。轮播右键是否应该隐藏。当我在最后一节。离开轮播应该隐藏。
谢谢!
这是我的javascript:
$(function () {
var background = $(".carousel-image")
buttonLeft = $(".carousel-left")
buttonRight = $(".carousel-right");
$("section").hide();
$("section:first").show();
buttonLeft.click(function (e) {
e.preventDefault();
background.animate({ left: "-=1000px" }, 1100, "easeOutQuad", function () {
$("section:visible").hide().next().fadeIn(600);
});
});
buttonRight.click(function (e) {
e.preventDefault();
background.animate({ left: "+=1000px" }, 1100, "easeOutQuad", function () {
$("section:visible").hide().prev().fadeIn(600);
});
});
});
【问题讨论】:
标签: javascript jquery html carousel