I want to insert an input(type=file) when I click the button using js but the input element appear for miliseconds and then right after it dissapears. Here's my code:
function addInputImg(){
var div2 = document.getElementById("imgFiles");
var inputImg = document.createElement('input');
inputImg.type = 'file';
div2.appendChild(inputImg);
}
<form ...>
.
.
<button id='btnAgregarImg' onclick="addInputImg();">Agregar imagen</button>
<div id='imgFiles'>
</div>
</form>