Best Way To Write JQuery's ReplaceWith() In Natural JavaScript
Answer :
var image = document.getElementById('imagefiles'), parent = image.parentNode, tempDiv = document.createElement('div'); tempDiv.innerHTML = "<input type='file' name='imagefiles' id='imagefiles' />" var input = tempDiv.childNodes[0]; parent.replaceChild(input, image);
DEMO
EDIT as per am not i am:
var image = document.getElementById('imagefiles'), parent = image.parentNode, input = document.createElement('input'); input.id = input.name = "imagefiles"; input.type = 'file'; parent.replaceChild(input, image);
Comments
Post a Comment