let inputs = document.querySelectorAll('.input__file');
Array.prototype.forEach.call(inputs, function (input) {
let label = input.nextElementSibling,
labelVal = label.querySelector('.input__file-button-text').innerText;
input.addEventListener('change', function (e) {
let countFiles = '';
if (this.files && this.files.length >= 1)
countFiles = this.files.length;
if (countFiles)
label.querySelector('.input__file-button-text').innerText = 'Selected files: ' + countFiles;
else
label.querySelector('.input__file-button-text').innerText = labelVal;
});
});
let inputs = document.querySelectorAll('.input__file');
Array.prototype.forEach.call(inputs, function (input) {
let label = input.nextElementSibling,
labelVal = label.querySelector('.input__file-button-text').innerText;
input.addEventListener('change', function (e) {
let countFiles = '';
if (this.files && this.files.length >= 1)
countFiles = this.files.length;
if (countFiles)
label.querySelector('.input__file-button-text').innerText = 'Selected files: ' + countFiles;
else
label.querySelector('.input__file-button-text').innerText = labelVal;
});
});