0

Here is my input code, I need to add a cross so that the input is cleared when clicked.

But without using the form only input and label


       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 = 'Выбрано файлов: ' + countFiles;
              
            else
              label.querySelector('.input__file-button-text').innerText = labelVal;
            
          
             
          });
            
        });
Andreas
  • 21,535
  • 7
  • 47
  • 56

0 Answers0