Then you can execute the animation after you get the data:
var $counter = $('#the_counter'),
$counterNum = $counter.find('.num');
// Configure counter data, default data on HTML data-{name} attribute will be used
// To overwrite animation values enter the data in object
$counterNum.data({
start: 0,
end: 500,
duration: 1000
});
// Execute animation
countableElement($counter);
This is basically the implementation. I hope it helps you.
I want to dynamically change the xe-counter without using angular?
If I do this in jQuery(document).ready:
document.getElementById(“num-attendee-widget”).dataset.to = ‘50’;
It will change.
Once the screen is drawn changing it with the code above has no affect. How do I execute the counter animation in javascript?
Hi markallenrupert,
Sure, I will tell you how exactly you can achieve this, firstly you need to add this function to your JS file:
On HTML you should add the counter container markup:
Then you can execute the animation after you get the data:
This is basically the implementation. I hope it helps you.