-4

I try create simple rotation of images each time , i try this but no works , basically i want repit and auto increment the "id" for show all images as transition

My Code :

<script>
function slider(id) {
    var n_image = 3;

    if (id == 0) {
        var i = 0;
    } else {
        var i = id + i;
    }

    setTimeout(function () {
        $(".im_" + i).fadeIn(2000).delay(2000).hide(1000);
    }, 1000);
}
</script>

The setTimeout call each 1 seconds and i want add one number more in each time for example the slide 1 slide 2 and continue and if the number it´s more of max images exists return the first number other time , and continue the loop

Thank´s for the help , the best regards

4

1 回答 1

0

对不起,我无法理解你的问题。您是否只想不断地旋转您提供的图像?看看下面的小提琴。

http://jsfiddle.net/denniswaltermartinez/f8mVj/

function slider(id) {
    id = id || 0;

    var n_image = $('[class^="img_"]').length;

    if (n_image < id) id -= n_image;

    setTimeout(function () {
        $('img:not(.img_'+ id +')').fadeOut('slow');
        $('.img_' + id).fadeIn('slow', function () {
            id++;
            slider(id);
        });
    }, 1000);
}
slider(1);

希望这会将您推向正确的方向。

于 2013-10-18T02:02:46.967 回答