Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
129 views
in Technique[技术] by (71.8m points)

javascript - 如何重设<input type = “file”>(how to reset <input type = “file”>)

I am developing a metro app with VS2012 and Javascript(我正在使用VS2012和Javascript开发Metro应用程序)

I want to reset the contents of my file input:(我想重置文件输入的内容:) <input type="file" id="uploadCaptureInputFile" class="win-content colors" accept="image/*" /> How should I do that?(我应该怎么做?)   ask by Jesus translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The jQuery solution that @dhaval-marthak posted in the comments obviously works, but if you look at the actual jQuery call it's pretty easy to see what jQuery is doing, just setting the value attribute to an empty string.(@ dhaval-marthak在评论中发布的jQuery解决方案显然有效,但是如果您查看实际的jQuery调用,则很容易看到jQuery在做什么,只需将value属性设置为一个空字符串即可。)

So in "pure" JavaScript it would be:(因此,在“纯” JavaScript中,它将是:) document.getElementById("uploadCaptureInputFile").value = "";

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...