Hitu Bansal
Hitu Bansal

Reputation: 3137

jquery animate slider onClick event

I am creating a slider using jquery animate function. The first image is moving to left and is working fine.But the next image is not quickly following the first image. It displays a blank screen for a while. This is what I have tried so far:

$('.next').live('click',function() {
            $('.ac_bgimage').animate({
                left:"-80em"    
            }, 1500 , function(){
                test();
                });                
        });
        function test() {

        $('.ac_bgimage').attr('src','images/2.jpg');
        $('.ac_bgimage').css('left','0em');
    }

I am stuck at this point. Please help. Thanks in advance.

Upvotes: 2

Views: 1919

Answers (2)

samir chauhan
samir chauhan

Reputation: 1543

Try this easy slider jquery plugin. This will solve your purpose.

Upvotes: 3

expertCode
expertCode

Reputation: 533

In your jsfiddle.net/cSVWv, you have two errors, because you have you div with 'next' class hidden, as thats is not possible to trigger the 'click' event. The other is, in image with 'ac_bgimage' class you need to the position relative to works.

See my example here: http://jsfiddle.net/expertCode/tvaMK/

Upvotes: 1

Related Questions