我有一个用 JQuery 定制的幻灯片;
$(document).ready(function () {
$animating_slideshow = false;
$animation_speed = 1000;
$amount_of_slides = $("#slider").find(".img-games").find(".img-game").length;
$("#slider-left").on("click", function() {
if (!$animating_slideshow) {
$slidden = parseInt($(this).parent().find(".img-games").css("margin-left"));
if ($slidden > 0 || $slidden < 0) {
$(this).parent().find(".img-games").animate({"margin-left":"+=170"}, $animation_speed, function() {
$animating_slideshow = false;
});
$animating_slideshow = true;
} else {
$(this).parent().find(".img-games").animate({"margin-left":-($amount_of_slides-1) * 170}, $animation_speed, function() {
$animating_slideshow = false;
});
$animating_slideshow = true;
}
}
});
$("#slider-right").on("click", function() {
if (!$animating_slideshow) {
$slidden = parseInt($(this).parent().find(".img-games").css("margin-left"));
if ($slidden > -($amount_of_slides-1) * 170) {
$(this).parent().find(".img-games").animate({"margin-left":"-=170"}, $animation_speed, function() {
$animating_slideshow = false;
});
$animating_slideshow = true;
} else {
$(this).parent().find(".img-games").animate({"margin-left":"0"}, $animation_speed, function() {
$animating_slideshow = false;
});
$animating_slideshow = true;
}
}
});
});
这是我的html...
<div id="slider">
<div class="img-games">
<div id="this_slide" class="img-game">
<img src="http://www.maxdamage.org/wp-content/uploads/2012/05/pokemon-gameboy.jpg" width='170px' height='115px' class='degrades' alt='pokemon' title='Pokemon'>
</div>
<div class="img-game">
<img src="http://1.bp.blogspot.com/-U62BIDPN79U/UV1hPr9xtAI/AAAAAAAAENs/mKIrEDb4RAw/s320/Super_mario_land.png" width='170px' height='115px' class='degrades' alt='Mario' title='Mario'>
</div>
<div class="img-game">
<img src="http://1.bp.blogspot.com/-J7x8JfY21Yk/UUea7UsjUZI/AAAAAAAAA0M/E2qpkAZFsnM/s1600/links_awakening2.png" width="170px" height="115px" class="degrades" alt='Zelda' title='Zelda'>
</div>
<div class="img-game">
<img src="http://www.consoleclassix.com/info_img/Rayman_GBC_ScreenShot2.gif" width="170px" height="115px" class="degrades" alt='Rayman' title='Rayman'>
</div>
</div>
</div>
我将如何向当前可以在屏幕上查看的图像添加一个名为“当前”的新类,任何帮助将不胜感激,在此先感谢!