Skip to content

Instantly share code, notes, and snippets.

@adinan-cenci
Created October 2, 2018 23:04
Show Gist options
  • Save adinan-cenci/d8016899a79a35178e90cdd22b9c0a49 to your computer and use it in GitHub Desktop.
Save adinan-cenci/d8016899a79a35178e90cdd22b9c0a49 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script>
function onClick(e)
{
var x, width, perc;
x = e.clientX - this.offsetLeft;
width = this.offsetWidth;
perc = Math.ceil((x / width) * 100);
this.value = perc;
}
document.addEventListener('DOMContentLoaded', function()
{
document.getElementById('progress-bar').addEventListener('click', onClick);
});
</script>
</head>
<body>
<progress id="progress-bar" value="0" max="100"></progress>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment