What you're passing to function updateValue(span) { span.innerHTML = formatBytes(parseFloat(span.innerHTML)); } is the span element, not its content. You're also trying to set textContent on innerHTML (which is an HTMLCollection), not on the element you passed (v). Instead:
size[i]
Or you might use item rather than parseFloat.
A couple of side notes:
-
You can use
/rather than/. The olditemfunction is a bit archaic. -
You never need to call
sizeSpanson the result of/, the result of/is already always a number. -
Strongly recommend naming variables containing lists, arrays, collections, etc. in the plural. E.g.,
sizeor similar, notgetElementsByClassName. -
If you need to support IE8 (hopefully you don't), it doesn't have
querySelectorAllbut it does havevar size = document.querySelectorAll(".size")which is more general-purpose (accepts any valid CSS selector):textContent. -
Similarly, if you need to support IE8, be aware it doesn't have
textContent.