怎么使用jquery 清空 input type="file" 的内容
如何使用jquery 清空 input type="file" 的内容
<input accept="" accessKey="" alt="" class="fileInput" dir="" lang="" name="j_id0:j_id10:fileName:inputFile:file" onblur="" onchange="" onclick="" ondblclick="" onfocus="" onkeydown="" onkeypress="" onkeyup="" onmousedown="" onmousemove="" onmouseout="" onmouseover="" size="" style="" tabindex="" title="" type="file" />
setInterval('ShowClearBtn()', 300);
});
function ShowClearBtn () {
if (jQuery('.fileInput').val() != ''){
jQuery('.clearBtn').css('visibility', 'visible');
}
}
在firefox and safari and 谷歌都没有问题。可以IE 就不行。我用的是IE 7.
请大家帮帮忙。在此谢过。
------解决方案--------------------
那就移除,再添加
------解决方案--------------------
------解决方案--------------------
<input accept="" accessKey="" alt="" class="fileInput" dir="" lang="" name="j_id0:j_id10:fileName:inputFile:file" onblur="" onchange="" onclick="" ondblclick="" onfocus="" onkeydown="" onkeypress="" onkeyup="" onmousedown="" onmousemove="" onmouseout="" onmouseover="" size="" style="" tabindex="" title="" type="file" />
setInterval('ShowClearBtn()', 300);
});
function ShowClearBtn () {
if (jQuery('.fileInput').val() != ''){
jQuery('.clearBtn').css('visibility', 'visible');
}
}
在firefox and safari and 谷歌都没有问题。可以IE 就不行。我用的是IE 7.
请大家帮帮忙。在此谢过。
------解决方案--------------------
那就移除,再添加
------解决方案--------------------
------解决方案--------------------
- JScript code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> </head> <body> <input type="file" id="files" /> <input type="button" id="btn" value="clear" /> <script type="text/javascript"> document.getElementById('btn').onclick = function() { var o = document.getElementById('files') if(!!document.all) { o.select(); document.execCommand("delete"); } else { o.value = ''; } } </script> </body> </html>
------解决方案--------------------
移除掉,再用jquery创建一个这样的标签