Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8573355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:13:48+00:00 2026-06-11T19:13:48+00:00

I’ve been working on a jQuery plugin to animate an element’s text between two

  • 0

I’ve been working on a jQuery plugin to animate an element’s text between two number values. jQuery’s animate function forces you to specify an attribute that you’re animating. In my case, I essentially need to call text() on each animation step so I had to do some finagling to get it to work.

Since I’m not using animate() in the normal fashion, I’ve exposed myself to conflicting animation since jQuery doesn’t handle it for me. For example, if I start animating my element’s text to “500” over 5 seconds and also immediately start animating the same element’s text to “500000” over 1 second, I get strange results because they’re conflicting with one other.

A picture is worth a thousand word, so here’s the jsFiddle:
http://jsfiddle.net/XjrNC/

My primary question is: What’s the most appropriate way to ensure that when I start a new animation that the previous animations are stopped.

My second question is: What’s your feedback on my code so far? Would you take a different approach?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T19:13:50+00:00Added an answer on June 11, 2026 at 7:13 pm

    I would just assign IDs instead of calling by class… this would be using your code, I made a considerable number of edits in my version, so I wouldn’t really even do this.

    $(function() {
        $('#oneThousand').tweenText(500, 5000);
        $('#fiveThousand').tweenText(500000, 1000);
    })
    

    In your code I felt the $.each inside of the tweenText wasn’t very useful, IMO that should be outside of the method. The concept is do this to the specified selectors, instead of making extra selections within the method.

    Also, I highly recommend using an object of arguments, rather than passing a pre-defined set, then ones which aren’t needed may be passed as null or just left out.

    Further, I added a callback function, so that you can setup things which run when the current tweenText is complete.

    Here are my modifications.

    http://jsfiddle.net/pmZHp/3/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am reading a book about Javascript and jQuery and using one of the
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I've tracked down a weird MySQL problem to the two different ways I was
I have a text area in my form which accepts all possible characters from
I'm trying to select an H1 element which is the second-child in its group

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.