HubSpot / odometer

Smoothly transitions numbers with ease. #hubspot-open-source
http://github.hubspot.com/odometer/docs/welcome
MIT License
7.31k stars 716 forks source link

multiple odometers #99

Closed kyoukhana closed 9 years ago

kyoukhana commented 9 years ago

I want to have multiple odometers on one page. How do I call the library using jQuery to do this. Also I have a data-set attribute so when calling the library from jQuery it will pull the value from there and display the Odometers.

<div class="odometer" data-start='5,000,000,000'>0</div>
kyoukhana commented 9 years ago

I figured it out

        jQuery('[data-theme]').each(function(){

            var v = jQuery(this).data('start');
            var o = new Odometer({
                el: this,
                value:0,
                theme: jQuery(this).data('theme')
            });
            o.render();
            setInterval(function(){
                o.update(v);
            }, 3000);
        });
adamschwartz commented 9 years ago

Glad you figured it out!