Skip to content

Instantly share code, notes, and snippets.

@simonlehmann
Last active April 6, 2017 07:11
Show Gist options
  • Save simonlehmann/30c882e880aace768042ab9ba391bdd5 to your computer and use it in GitHub Desktop.
Save simonlehmann/30c882e880aace768042ab9ba391bdd5 to your computer and use it in GitHub Desktop.
Calculate Bootstrap progress-bar width percentage from aria values
$(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