如何删除“没有选择的文件”从Chrome中的文件输入中提取工具提示? [英] How can I remove the "No file chosen" tooltip from a file input in Chrome?

查看:98
本文介绍了如何删除“没有选择的文件”从Chrome中的文件输入中提取工具提示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从Google Chrome中输入的文件中删除未选择文件工具提示(我发现Firefox中没有显示工具提示)。

I would like to remove the "No file chosen" tooltip from a file input in Google Chrome (I see that no tooltip is displayed in Firefox).

请注意我不是关于输入字段内的文本,而是关于当您将鼠标移动到输入上时出现的工具提示。

Please notice that I'm talking not about the text inside the input field, but about the tooltip that appears when you move the mouse over the input.

我试过这个没有运气:

$('#myFileInput').attr('title', '');


推荐答案

浏览器,您无法将其移除。您应该考虑像覆盖或隐藏文件输入的黑客解决方案。

This is a native part of the webkit browsers and you cannot remove it. You should think about a hacky solution like covering or hiding the file inputs.

A hacky 解决方案:

A hacky solution:

input[type='file'] {
  opacity:0    
}



<div>
    <input type='file'/>
    <span id='val'></span>
    <span id='button'>Select File</span>
</div>   



$('#button').click(function(){
   $("input[type='file']").trigger('click');
})

$("input[type='file']").change(function(){
   $('#val').text(this.value.replace(/C:\\fakepath\\/i, ''))
})    

a href =http://jsfiddle.net/a8qN2/>小提琴

Fiddle

这篇关于如何删除“没有选择的文件”从Chrome中的文件输入中提取工具提示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆