Created
July 6, 2015 20:01
-
-
Save cbourdage/7bc0be0f5aa3641e5646 to your computer and use it in GitHub Desktop.
html incrementing js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('.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