In jquery I am trying to clear a field, but if I do, it throws an error. It does make the field go empty, but also throws an error. How can I fix that?
Thanks
HTML
<input name="file" type="file" accept="image/*">
JS
var input = $("#profile-edit-form").find("input[name=file]");
var fileName = input.val();
if(fileName) { // returns true if the string is not empty
input.replaceWith(input.val('').clone(true));
}
ERROR
NotFoundError: Node was not found
-jquery.min.js:3:0