JSFiddle - React, Tailwind, and code Playground

by Chris Buttery

HTML

<form></form>

JavaScript

function Upload() {
    this.el = document.createElement('input');
    this.el.setAttribute('type', 'file');
    this.el.addEventListener('change', this.onChange.bind(this));
}

Upload.prototype.appendTo = function(node) {
  node.appendChild(this.el);  
};

Upload.prototype.onChange = function(){
   setTimeout(this.hide.bind(this), 2000);
   var next = new Upload();
   next.appendTo(this.el.parentNode);
};

Upload.prototype.hide = function(){
    this.el.style.display = 'none';
};

//  Do things

var upload = new Upload();
upload.appendTo(document.querySelector('form'));