Safari/Chrome中placeholder属性实现不完整

placeholder属性是HTML5中提出的,目前Firefox/Safari/Chrome/Opera都已经实现了。IE9仍然没实现。

但Safari/Chrome中有个问题,点击文本框内文字不消失。

如下

<!DOCTYPE html>
<html>
	<head>
		<title>Safari/Chrome中placeholder属性实现不完整</title>
		<meta charset="utf-8">
	</head>
	<body>
		<p>
			<input type="text" placeholder="username"/>
		</p>
	</body>
</html>

运行后将鼠标点入input输入框内,各浏览器表现如下。

Firefox/Opera中文字消失

Safari/Chrome中文字不消失

IE6/7/8/9不支持该属性,即不出现文字提示

相关:

http://www.w3.org/TR/html5/common-input-element-attributes.html#attr-input-placeholder

https://developer.mozilla.org/en/HTML/Element/input#attr-placeholder

原文地址:https://www.cnblogs.com/snandy/p/2457374.html