Last active
April 6, 2017 07:11
-
-
Save simonlehmann/30c882e880aace768042ab9ba391bdd5 to your computer and use it in GitHub Desktop.
Calculate Bootstrap progress-bar width percentage from aria values
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
$(document).ready -> | |
$('.progress-bar').each (i, obj) -> | |
value = Number($(obj).attr('aria-valuenow')) | |
range = Number($(obj).attr('aria-valuemax')) - Number($(obj).attr('aria-valuemin')) | |
percentage = ((value/range) * 100).toFixed(2) | |
# console.log "Value: #{value}, Range: #{range}, Percentage: #{percentage}" | |
$(obj).css("width", percentage + '%') | |
return | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment