将占位符属性放在文件类型输入字段上 [英] Putting placeholder attribute on file type input field

查看:105
本文介绍了将占位符属性放在文件类型输入字段上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种方法可以为文件类型的输入字段添加占位符



我已经尝试过jquery水印插件并不起作用。

解决方案

占位符属性不应该用于< input type =file> 。占位符用于提示输入。由于文件输入本身就是一个浏览按钮,显然它是用于选择文件的。如果没有选择文件,它会在按钮旁边显示没有选择文件。

因为


  1. 在某些浏览器中,它只显示为一个按钮。

  2. 它已经有默认文本,不能更改。
  3. >
  4. 每个浏览器都以自己的方式呈现。

  5. IE不支持占位符文本。


Is there a way to put a placeholder for input field which are file type?

I already tried jquery watermark plugin and it doesn't work.

解决方案

Placeholder attribute should not be used for <input type="file">. Placeholders are used to give a hint about the input. And as file input is itself a browse button, it is clearly seen that it is for choosing a file. And if there's no file chosen it shows "no file chosen" next to the button.

Because:

  1. In some browsers it just shows up as a button.
  2. It already have default text which can not be changed.
  3. Each browser renders it in own way.
  4. IE will not support placeholder text.

这篇关于将占位符属性放在文件类型输入字段上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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