我已经建立了一个水平手风琴,点击动画。我想为其添加自动旋转功能,以便幻灯片每三秒自行旋转一次,但我无法弄清楚这部分......
这是水平手风琴的代码:
<div id="slideshow">
<ol id="slides">
<li class="slide open active" id="slide-1">
<a href="recipe_detail.aspx?did=1014"><img src="media/images/recipes/featured-tuna-chop-chop-salad.jpg" alt="" /></a>
<a class="slidebutton" href="javascript:void(0);"></a>
</li>
<li class="slide open" id="slide-2">
<a href="recipe_detail.aspx?did=1016"><img src="media/images/recipes/featured-tuna-rolls-with-GS-sauce.jpg" alt="" /></a>
<a class="slidebutton" href="javascript:void(0);"></a>
</li>
<li class="slide open" id="slide-3">
<a href="recipe_detail.aspx?did=1101"><img src="media/images/recipes/featured-salmon-breakfast-strudel.jpg" alt="" /></a>
<a class="slidebutton" href="javascript:void(0);"></a>
</li>
<li class="slide open" id="slide-4">
<a href="recipe_detail.aspx?did=775"><img src="media/images/recipes/featured-chunky-tuna-potato-salad.jpg" alt="" /></a>
<a class="slidebutton" href="javascript:void(0);"></a>
</li>
<li class="slide open" id="slide-5">
<a href="recipe_detail.aspx?did=988"><img src="media/images/recipes/featured-clam-and-artichoke-mini.jpg" alt="" /></a>
<a class="slidebutton" href="javascript:void(0);"></a>
</li>
<li class="slide open" id="slide-6">
<a href="recipe_detail.aspx?did=598"><img src="media/images/recipes/featured-salmon-party-app.jpg" alt="" /></a>
<a class="slidebutton" href="javascript:void(0);"></a>
</li>
<li class="slide open" id="slide-7">
<a href="recipe_detail.aspx?did=425"><img src="media/images/recipes/featured-tortellini-tuna-salad.jpg" alt="" /></a>
<a class="slidebutton" href="javascript:void(0);"></a>
</li>
</ol>
<ol id="slidecontents">
<li class="slidecontent open" id="content-slide-1">
<p><span class="featureRecipeTitle">Stir Fried “Chop Chop” Salad</span></p>
<div class="recipeSliderGetRecipe"><a href="recipe_detail.aspx?did=1014"><img src="media/images/recipes/button-get-the-recipe.png"></a></div>
</li>
<li class="slidecontent" id="content-slide-2">
<p><span class="featureRecipeTitle">Tuna Rolls with Fresh Ginger Dipping Sauce</span></p>
<div class="recipeSliderGetRecipe"><a href="recipe_detail.aspx?did=1016"><img src="media/images/recipes/button-get-the-recipe.png"></a></div>
</li>
<li class="slidecontent" id="content-slide-3">
<p><span class="featureRecipeTitle">Mermaid's Breakfast Strudel</span></p>
<div class="recipeSliderGetRecipe"><a href="recipe_detail.aspx?did=1101"><img src="media/images/recipes/button-get-the-recipe.png"></a></div>
</li>
<li class="slidecontent" id="content-slide-4">
<p><span class="featureRecipeTitle">Chunky Tuna Potato Salad</span></p>
<div class="recipeSliderGetRecipe"><a href="recipe_detail.aspx?did=775"><img src="media/images/recipes/button-get-the-recipe.png"></a></div>
</li>
<li class="slidecontent" id="content-slide-5">
<p><span class="featureRecipeTitle">Clam & Artichoke Mini Melts</span></p>
<div class="recipeSliderGetRecipe"><a href="recipe_detail.aspx?did=988"><img src="media/images/recipes/button-get-the-recipe.png"></a></div>
</li>
<li class="slidecontent" id="content-slide-6">
<p><span class="featureRecipeTitle">Salmon Party Spread Appetizer</span></p>
<div class="recipeSliderGetRecipe"><a href="recipe_detail.aspx?did=598"><img src="media/images/recipes/button-get-the-recipe.png"></a></div>
</li>
<li class="slidecontent" id="content-slide-7">
<p><span class="featureRecipeTitle">Tortellini Tuna Salad</span></p>
<div class="recipeSliderGetRecipe"><a href="recipe_detail.aspx?did=425"><img src="media/images/recipes/button-get-the-recipe.png"></a></div>
</li>
</ol>
这是附属于它的javascript:
$(document).ready(function() {
$('#nav li').hover(function() {
$(this).addClass('hover');
}, function() {
$(this).removeClass('hover');
});
$('.slide')
.bind('open', function() {
if(! $(this).hasClass('open')) {
$(this).next().trigger('open');
$(this).addClass('open');
$(this).animate({right: "-=423px"});
} else {
$(this).prev().trigger('close');
}
$(this).siblings().removeClass('active');
$(this).addClass('active');
})
.bind('close', function() {
if($(this).hasClass('open')) {
$(this).removeClass('open');
$(this).animate({right: "+=423px"});
$(this).prev().trigger('close');
}
});
$('.slidebutton').click(function() {
$(this).parent().trigger('open');
$('#content-' + $(this).parent().attr('id')).trigger('show');
});
$('.slidecontent').bind('show', function() {
$('.slidecontent').removeClass('open');
$(this).addClass('open');
});
$('#nav>li').hover(function() {
$(this).addClass('hover');
}, function() {
$(this).removeClass('hover');
});
});
如果有人对我有智慧让幻灯片每 3 秒自动旋转一次,那就太棒了。谢谢你!