在IE10中保持占位符的重点 [英] keep placeholder on focus in IE10

查看:163
本文介绍了在IE10中保持占位符的重点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在WebKit和Firefox下,输入占位符中的文字附在 focus -it直到 input.val 才会消失。

Under WebKit and Firefox, the text in a input's placeholder sticks around on focus—it doesn't disappear until input.val actually has something in it.

有没有一种方法可以强迫IE10做同样的事情?

Is there a good way to force IE10 to do the same thing?

推荐答案

: - ms-input-placeholder伪类文档来自 Internet Explorer开发人员中心似乎暗示这是按设计工作的。

The :-ms-input-placeholder pseudo-class documentation from the Internet Explorer Developer Center seems to imply this is working as designed.


占位符文本以指定的样式显示,直到
字段具有焦点,这意味着可以输入字段。当
字段具有焦点时,它将返回到输入字段的正常样式,并且
占位符文本消失。

The placeholder text is displayed with the specified style until the field has focus, meaning that the field can be typed into. When the field has focus, it returns to the normal style of the input field and the placeholder text disappears.

编辑:如果我必须模仿这种行为,我会查看占位符polyfill库(设置默认值,在输入框上浮动灰色文本等),它们适用于旧版本的IE浏览器。它们必须被修改,因为它们可能具有检测占位符功能并遵循浏览器的功能。此外,这将有一个浏览器检测代码气味。

If I had to mimic this behavior, I would look at placeholder polyfill libraries (that set the default value, float grey text over the input box, etc) which work with older versions of IE. They would have to be modified, because they probably feature detect the placeholder capability and defer to the browser. Also, this would have a "browser detect" code smell.

更新: IE占位符文本消失问题在Twitter期间被询问#AskIE 2014年6月19日的问题会议和 @IEDevChat 已回复我们对此行为存在活动错误。下一版本将提供修复

Update: An "IE placeholder text disappears" question was asked during a Twitter #AskIE question session on June 19, 2014 and @IEDevChat responded "We have an active bug for this behavior. Next version will provide a fix"

这篇关于在IE10中保持占位符的重点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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