Skip to content

Instantly share code, notes, and snippets.

@b-aleksei
Created June 3, 2020 02:45
Show Gist options
  • Save b-aleksei/03f6d84caf5bb5b8e0939cdb77fba64e to your computer and use it in GitHub Desktop.
Save b-aleksei/03f6d84caf5bb5b8e0939cdb77fba64e to your computer and use it in GitHub Desktop.
progress
progressBar = document.querySelector('progress');
output = document.querySelector('output');
xhr.upload.addEventListener('progress', function (e) {
if (e.lengthComputable) {
var v = (e.loaded / e.total) * 100;
progressBar.value = v;
output.value = Math.round(v) + '%';
progressBar.textContent = progressBar.value.toString(); // Если браузер не поддерживает элемент progress
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment