Internet Explorer 10 and 11 remove placeholder text when the input is focused

When using Internet Explorer 10 and 11, input placeholder text is removed if the input is focused using the autofocus attribute. For example:

<input type="textbox" value="" placeholder="Example text" autofocus>

Demo: https://jsfiddle.net/ompkwtz5/

How can I ensure the placeholder text isn't removed?

Ref: https://connect.microsoft.com/IE/feedback/details/885747/ie-11-fires-the-input-event-when-a-input-field-with-placeholder-is-focused


It's an IE bug, the one in your reference link.

Take a look at jquery-placeholder. Will also support IE6! I'm not sure if it will work out of the box though, because IE10 is supposed to support the placeholder attribute, so check if jQuery.fn.placeholder.input is true (more info in the README). If it is, the plugin won't do anything, so you might need to override its checking behaviour.

Amazing that the bug is still active.

链接地址: http://www.djcxy.com/p/70560.html

上一篇: 如何在焦点上显示占位符文本?

下一篇: 重点关注输入时,Internet Explorer 10和11将删除占位符文本