Having trouble with a function hitting the page as soon as possible, so i need to write it in pure javascript and include it in the head. not sure how to go about it, because as i understand it, by using .replace() the new element will be moved to a different location on the page. jQuery's replaceWith() behavior is ideal.
$("#imagefiles").replaceWith("<input type='file' name='imagefiles' id='imagefiles' />");
.replace()
is for strings. Please don't use it for DOM. Could you describe your issue a little better? Are you saying you want an element to be replaced as soon as it appears, and not wait for the rest of the DOM to be ready? – Bisutun