How to count two different values and not stopping the same time











up vote
0
down vote

favorite












I am using jquery.countTo to count two different values but the issue is, the count start at the same time and stop at the same time even though the values are different. How can I start the count at the same time and stop when the value reaches its peak. for example, 216 should stop when it reaches 216 whilst 249 keeps counting until it reaches 249. Thanks



$('#cat-'+catNum+' span#asp-1-ev').countTo({from: 1,to: 249,speed:50000});
$('#cat-'+catNum+' span#asp-2-ev').countTo({from: 1,to: 216,speed:50000});









share|improve this question


















  • 1




    Numeric-indexed IDs are a code smell - consider using classes instead.
    – CertainPerformance
    Nov 11 at 8:46










  • Ok got that, but any help about the question asked
    – Big Pee
    Nov 11 at 8:51















up vote
0
down vote

favorite












I am using jquery.countTo to count two different values but the issue is, the count start at the same time and stop at the same time even though the values are different. How can I start the count at the same time and stop when the value reaches its peak. for example, 216 should stop when it reaches 216 whilst 249 keeps counting until it reaches 249. Thanks



$('#cat-'+catNum+' span#asp-1-ev').countTo({from: 1,to: 249,speed:50000});
$('#cat-'+catNum+' span#asp-2-ev').countTo({from: 1,to: 216,speed:50000});









share|improve this question


















  • 1




    Numeric-indexed IDs are a code smell - consider using classes instead.
    – CertainPerformance
    Nov 11 at 8:46










  • Ok got that, but any help about the question asked
    – Big Pee
    Nov 11 at 8:51













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I am using jquery.countTo to count two different values but the issue is, the count start at the same time and stop at the same time even though the values are different. How can I start the count at the same time and stop when the value reaches its peak. for example, 216 should stop when it reaches 216 whilst 249 keeps counting until it reaches 249. Thanks



$('#cat-'+catNum+' span#asp-1-ev').countTo({from: 1,to: 249,speed:50000});
$('#cat-'+catNum+' span#asp-2-ev').countTo({from: 1,to: 216,speed:50000});









share|improve this question













I am using jquery.countTo to count two different values but the issue is, the count start at the same time and stop at the same time even though the values are different. How can I start the count at the same time and stop when the value reaches its peak. for example, 216 should stop when it reaches 216 whilst 249 keeps counting until it reaches 249. Thanks



$('#cat-'+catNum+' span#asp-1-ev').countTo({from: 1,to: 249,speed:50000});
$('#cat-'+catNum+' span#asp-2-ev').countTo({from: 1,to: 216,speed:50000});






jquery






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 11 at 8:45









Big Pee

54




54








  • 1




    Numeric-indexed IDs are a code smell - consider using classes instead.
    – CertainPerformance
    Nov 11 at 8:46










  • Ok got that, but any help about the question asked
    – Big Pee
    Nov 11 at 8:51














  • 1




    Numeric-indexed IDs are a code smell - consider using classes instead.
    – CertainPerformance
    Nov 11 at 8:46










  • Ok got that, but any help about the question asked
    – Big Pee
    Nov 11 at 8:51








1




1




Numeric-indexed IDs are a code smell - consider using classes instead.
– CertainPerformance
Nov 11 at 8:46




Numeric-indexed IDs are a code smell - consider using classes instead.
– CertainPerformance
Nov 11 at 8:46












Ok got that, but any help about the question asked
– Big Pee
Nov 11 at 8:51




Ok got that, but any help about the question asked
– Big Pee
Nov 11 at 8:51












1 Answer
1






active

oldest

votes

















up vote
0
down vote



accepted










The speed option defines how long it should take to reach the finish. Since you put the same value for both counters, they will finish at the same time.



See documentation:




speed | data-speed | The number of milliseconds it should take to finish counting. (default: 1000)




If you want the increments in both widgets to happen with equal intervals, then you could calculate this speed option dynamically:



const speed = 200;
$('#a').countTo({from: 1, to: 249, speed: 249*speed});
$('#b').countTo({from: 1, to: 216, speed: 216*speed});





share|improve this answer





















  • Thanks. I tried your solution and it worked perfectly.
    – Big Pee
    Nov 11 at 9:00












  • You're welcome ;-)
    – trincot
    Nov 11 at 9:14











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53247122%2fhow-to-count-two-different-values-and-not-stopping-the-same-time%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote



accepted










The speed option defines how long it should take to reach the finish. Since you put the same value for both counters, they will finish at the same time.



See documentation:




speed | data-speed | The number of milliseconds it should take to finish counting. (default: 1000)




If you want the increments in both widgets to happen with equal intervals, then you could calculate this speed option dynamically:



const speed = 200;
$('#a').countTo({from: 1, to: 249, speed: 249*speed});
$('#b').countTo({from: 1, to: 216, speed: 216*speed});





share|improve this answer





















  • Thanks. I tried your solution and it worked perfectly.
    – Big Pee
    Nov 11 at 9:00












  • You're welcome ;-)
    – trincot
    Nov 11 at 9:14















up vote
0
down vote



accepted










The speed option defines how long it should take to reach the finish. Since you put the same value for both counters, they will finish at the same time.



See documentation:




speed | data-speed | The number of milliseconds it should take to finish counting. (default: 1000)




If you want the increments in both widgets to happen with equal intervals, then you could calculate this speed option dynamically:



const speed = 200;
$('#a').countTo({from: 1, to: 249, speed: 249*speed});
$('#b').countTo({from: 1, to: 216, speed: 216*speed});





share|improve this answer





















  • Thanks. I tried your solution and it worked perfectly.
    – Big Pee
    Nov 11 at 9:00












  • You're welcome ;-)
    – trincot
    Nov 11 at 9:14













up vote
0
down vote



accepted







up vote
0
down vote



accepted






The speed option defines how long it should take to reach the finish. Since you put the same value for both counters, they will finish at the same time.



See documentation:




speed | data-speed | The number of milliseconds it should take to finish counting. (default: 1000)




If you want the increments in both widgets to happen with equal intervals, then you could calculate this speed option dynamically:



const speed = 200;
$('#a').countTo({from: 1, to: 249, speed: 249*speed});
$('#b').countTo({from: 1, to: 216, speed: 216*speed});





share|improve this answer












The speed option defines how long it should take to reach the finish. Since you put the same value for both counters, they will finish at the same time.



See documentation:




speed | data-speed | The number of milliseconds it should take to finish counting. (default: 1000)




If you want the increments in both widgets to happen with equal intervals, then you could calculate this speed option dynamically:



const speed = 200;
$('#a').countTo({from: 1, to: 249, speed: 249*speed});
$('#b').countTo({from: 1, to: 216, speed: 216*speed});






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 11 at 8:53









trincot

114k1477109




114k1477109












  • Thanks. I tried your solution and it worked perfectly.
    – Big Pee
    Nov 11 at 9:00












  • You're welcome ;-)
    – trincot
    Nov 11 at 9:14


















  • Thanks. I tried your solution and it worked perfectly.
    – Big Pee
    Nov 11 at 9:00












  • You're welcome ;-)
    – trincot
    Nov 11 at 9:14
















Thanks. I tried your solution and it worked perfectly.
– Big Pee
Nov 11 at 9:00






Thanks. I tried your solution and it worked perfectly.
– Big Pee
Nov 11 at 9:00














You're welcome ;-)
– trincot
Nov 11 at 9:14




You're welcome ;-)
– trincot
Nov 11 at 9:14


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53247122%2fhow-to-count-two-different-values-and-not-stopping-the-same-time%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Xamarin.iOS Cant Deploy on Iphone

Glorious Revolution

Dulmage-Mendelsohn matrix decomposition in Python