在jquery中我试图清除一个字段,但是如果我这样做,它会抛出一个错误。它确实使字段变空,但也会引发错误。我该如何解决这个问题?如何清除jQuery中的输入文件字段?
感谢
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
你能重现错误还是提供更多上下文? – undefined 2015-02-08 20:13:06