Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
$('.counter-count').each(function () {
$(this).prop('Counter',0).animate({
Counter: $(this).text()
}, {
duration: 5000,
easing: 'swing',
step: function (now) {
$(this).text(Math.ceil(now));
}
});
});

What I have tried:

I was trying to convert that jquery to typescript but I'm getting error someone please help me for convert jquery number animation to typescript.
Posted
Updated 22-Jan-19 22:49pm
Comments
Richard MacCutchan 12-Nov-18 5:24am    
Why do you not explain what the error is?

1 solution

Without seeing your code, I am going to have to make some assumptions.

The first is that you haven't figured out what the purpose of the $ is at the start. That's an alias for JQuery itself so this part $(`.counter-count`) is effectively an alias for document.getElementsByClassName(`counter-count`);. Now, that returns an array so you can use something like forEach to iterate over it. If you use the fat arrow function implementation, you will get an explicitly captured this so you can discount $(this). This part would look a little bit like this
JavaScript
theClassArray.forEach(element => {
  // element takes the place of $(this)
});
As I don't know what else is wrong with your code, I'll leave it up to you - but you should have enough hints here.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900