Skip to content

Instantly share code, notes, and snippets.

@cbourdage
Created July 6, 2015 20:01
Show Gist options
  • Save cbourdage/7bc0be0f5aa3641e5646 to your computer and use it in GitHub Desktop.
Save cbourdage/7bc0be0f5aa3641e5646 to your computer and use it in GitHub Desktop.
html incrementing js
$('.merrits').find('.num')
.each(function() {
// set each .num back to zero and add a class to look for
var $t = $(this);
$t.data('number', $t.html());
$t.html('0');
})
.on('in.Inview', function() {
$(this).data('interval', window.setInterval($.proxy(function() {
var $t = $(this),
num = parseInt($t.html()) + 1;
$t.html(num);
if (num >= +$t.data('number')) {
clearInterval($(this).data('interval'));
}
}, this), 5));
})
.Inview();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment