Html 如何将“选择文件”更改为“浏览”?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5281430/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 07:18:50  来源:igfitidea点击:

How to change “Choose file” into “Browse”?

htmlfileinputtypes

提问by user634850

I want to change the default value of <input type="file" />from “Choose file” to “Browse”. How to do that?

我想将<input type="file" />“选择文件”的默认值更改为“浏览”。怎么做?

回答by fubo

Hide it and use a other control to trigger it.

隐藏它并使用其他控件来触发它。

<a href="#" onclick="document.getElementById('fileID').click(); return false;" />Browse</a>
<input type="file" id="fileID" style="visibility: hidden;" />

回答by dalvarezmartinez1

I created a jsFiddle to show how, you can find it here: Custom browse button

我创建了一个 jsFiddle 来展示如何,你可以在这里找到它: Custom browse button

回答by sbrbot

Here is another solution; hiding file-type input field (button) and placing another regular button-type input field (button) which allows one to change its content - triggering first file button (lower one) is done with JavaScript clicking on second regular button (upper one).

这是另一个解决方案;隐藏文件类型输入字段(按钮)并放置另一个允许更改其内容的常规按钮类型输入字段(按钮) - 触发第一个文件按钮(下部)是通过 JavaScript 单击第二个常规按钮(上部)完成的.

Howto Style the Button of a input type="file" Control

如何为 input type="file" 控件的按钮设置样式