var cont = 0; function addFile(){ cont++; document.getElementById('cont').value = cont; var alvo = document.getElementById('ul_file'); var li = document.createElement('li'); var inp = document.createElement('input'); inp.setAttribute('type','file'); inp.setAttribute('name','file'+ cont); inp.setAttribute('id','file'+ cont); li.appendChild(inp) var link = document.createElement('a'); link.setAttribute('href','#'); link.onclick = function(){ cont--; document.getElementById('cont').value = cont; li.parentNode.removeChild(li); return false; } link.innerHTML = 'remover'; li.appendChild(link); alvo.appendChild(li); return false; } window.onload = function(){ document.getElementById('add_file').onclick = addFile; }