var file = document.getElementById('file'), removeBtn = document.getElementById('remove'); removeBtn.addEventListener('click', function() { file.value = ''; }, false); <input type="file" id="file"/> <br /> <input type="button" id="remove" value="remove" /> <br /> <br /> <input type="file" id="file"/> <br /> <input type="button" id="remove" value="remove" /> <br /> <br /> <input type="file" id="file"/> <br /> <input type="button" id="remove" value="remove" /> <br /> <br /> How to change the script correctly so that only the file under which the delete button is located can be deleted?