最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - Text animation from left and right in continuous loop using jquery - Stack Overflow

matteradmin5PV0评论

I want to animate text smoothly from left and right in continuous loop can anyone suggest me something here is the fiddle link: /

 $(document).ready(function () {
    $('.kp').animate({
        left: '10px'
    }, 600);
    $('.kp').delay(600).animate({
        left: '-128px'
    }, 600);
    $('.rp').delay(2000).animate({
        left: '10px'
    }, 600);
    $('.rp').delay(600).animate({
        left: '-108px'
    }, 600);
    $('.kpp').delay(4000).animate({
        left: '10px'
    }, 600);
});

I want to animate text smoothly from left and right in continuous loop can anyone suggest me something here is the fiddle link: http://jsfiddle/yLNGn/3/

 $(document).ready(function () {
    $('.kp').animate({
        left: '10px'
    }, 600);
    $('.kp').delay(600).animate({
        left: '-128px'
    }, 600);
    $('.rp').delay(2000).animate({
        left: '10px'
    }, 600);
    $('.rp').delay(600).animate({
        left: '-108px'
    }, 600);
    $('.kpp').delay(4000).animate({
        left: '10px'
    }, 600);
});
Share Improve this question edited Aug 31, 2013 at 8:47 Vignesh Pichamani 8,07022 gold badges80 silver badges117 bronze badges asked Aug 31, 2013 at 8:04 RonakRonak 412 silver badges7 bronze badges 1
  • So you want to run the sequence you've posted above and then re-start that sequence so that it continues to run in perpetuity? Or is there another aspect to your question? – David Thomas Commented Aug 31, 2013 at 8:47
Add a ment  | 

3 Answers 3

Reset to default 1

See Here is the answer. I make it as the seperate function with fiddle see here.

function repeat() {
    $('.kp').animate({
    left: '10px'
}, 600);
$('.kp').delay(600).animate({
    left: '-128px'
}, 600);
$('.rp').delay(2000).animate({
    left: '10px'
}, 600);
$('.rp').delay(600).animate({
    left: '-108px'
}, 600);
$('.kpp').delay(4000).animate({
    left: '10px'
}, 600);
    $('.kpp').delay(600).animate({
        left:'-108px'
   },600 ,function() {
        repeat();
    });
}

Fiddle

Hopefully it may helps.

Well, you can use setInterval function, or if you make use of the plete callback of the jquery animate method:

$(document).ready(function () {
  console.log('ready');

  var james = $('#bond');

  var right = function () {
    james.animate({left: '100px'}, 600, left);
  };

  var left = function () {
    james.animate({left: '0px'}, 600, right);
  };

  right();
});

this is the plete fiddle example: http://jsfiddle/yLNGn/32/

Have you considered using this jQuery plugin?

Post a comment

comment list (0)

  1. No comments so far