有什么方法我可以停止no file chosen输入类型文件" ".
<input type="file" id="field-id" name="html" />
Run Code Online (Sandbox Code Playgroud)
Eri*_*ass 15
您无法完全摆脱"没有选择的文件",但您可以通过设置标题将文本更改为有意义的内容.
<input type="file" title="foo">
Run Code Online (Sandbox Code Playgroud)
将在鼠标悬停时显示"foo"而不是"未选择文件"
不幸,
<input type="file" title="">
Run Code Online (Sandbox Code Playgroud)
不像你希望的那样工作.
最简单(据我所知,可靠)hack我发现将初始字体颜色设置为透明以隐藏"无文件选择"文本,然后将字体颜色更改为更改时可见的内容.
瞧:
<input type="file" style="color:transparent;" onchange="this.style.color = 'black';"/>
Run Code Online (Sandbox Code Playgroud)
对于Chrome浏览器,您可以使用此类技巧:
<input type="file" id="myFile" name="html" style="width: 90px;" onchange="this.style.width = '100%';" />
Run Code Online (Sandbox Code Playgroud)
含义设置固定宽度,仅显示按钮,然后在更改后将其更改回100%,以便显示文件名.
| 归档时间: |
|
| 查看次数: |
60726 次 |
| 最近记录: |