jQuery:获取从 <input type="file" 中选择的文件名/> [英] jQuery: get the file name selected from <input type="file" />
本文介绍了jQuery:获取从 <input type="file" 中选择的文件名/>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这段代码应该可以在 IE 中工作(甚至不要在 Firefox 中测试它),但它没有.我想要的是显示附件的名称.有什么帮助吗?
<头><title>示例</title><script type="text/javascript" src="../js/jquery.js"></script><script type="text/javascript">$(document).ready(函数(){$("#attach").after("");$("#fakeAttach").click(function() {$("#attach").click();$("#maxSize").after("<div id='temporary'><span id='attachedFile'></span><input id='remove' type='button' value='remove'/>
");$('#attach').change(function(){$("#fakeAttach").attr("disabled","disabled");$("#attachedFile").html($(this).val());});$("#remove").click(function(e){e.preventDefault();$("#attach").replaceWith($("#attach").clone());$("#fakeAttach").attr("disabled","");$("#temporary").remove();});})});头部><身体><input id="attach" type="file"/><span id="maxSize">(小于1MB)</span>