Skip to content

Instantly share code, notes, and snippets.

@frankstallone
Created January 16, 2014 18:34
Show Gist options
  • Save frankstallone/8460618 to your computer and use it in GitHub Desktop.
Save frankstallone/8460618 to your computer and use it in GitHub Desktop.
Generic function for a progress bar. Made with Zurb Foundation in mind.
function progressBar(v) {
'use strict';
var value = parseInt(v);
var currentBar = parseInt($('.meter')[0].style.width.replace(/[^\d]/g, ''));
var newBar = value + currentBar;
if (value + currentBar > 100) {
$('.meter').css('width', '100%');
} else if (value + currentBar < 0) {
$('.meter').css('width', '0%');
} else {
$('.meter').css('width', newBar + '%');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment