JQuery占位符插件placeholders.jquery.js,placeholder这个属性在低版本的IE或者QQ浏览器等这些浏览器上这个属性不能生效,可以使用这个placeholder.js插件。
(附件中附有详细使用Demo)
![]() |
---|
简单使用
$(function () {
$('input,textarea').placeholder();
});
这将为Internet Explorer 7和8的文本输入和文本区域上的占位符属性提供故障切换
<input type="text" name="emailAddress" placeholder="Enter your email address" />
<textarea name="about" placeholder="Tell us about yourself" />
<script src="jquery-placeholder.js">
<script>
$('input[type=text], textarea').placeholder();
</script>
此方法可用于为Internet Explorer 6添加故障转移
<input type="text" name="emailAddress" />
<input type="text" name="firstName" />
<input type="text" name="lastName" />
<script src="jquery-placeholder.js">
<script>
$('input[name=emailAddress]').placeholder('Enter your email address');
$('input[name=firstName]').placeholder('Enter your first name');
$('input[name=lastName]').placeholder('Enter your last name');
</script>
相关链接
GitHub 地址 : https://github.com/serby/jquery.placeholder.js