jquery文本框提示信息
2011-08-20 21:28
381 查看
文本框输入提示语在,在用户设置的的时候经常性的使用,还是jquery好用,自定义一个属性,把要提示的信息全部写在自定义的属性里面。真是方便极了,还以重复调用。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script type="text/javascript" language="javascript" src="Js/jquery.js"></script>
<script type="text/javascript" language="javascript">
$(function(){
$("[placeholder]").css("color","#ccc")
$("[placeholder]").focus(function() {
var input = $(this);
if (input.val() == input.attr("placeholder")) {
input.val("");
input.removeClass("placeholder");
}
}).blur(function() {
var input = $(this);
if (input.val() == "" || input.val() == input.attr("placeholder")) {
input.addClass("placeholder");
input.val(input.attr("placeholder"));
}
}).blur();
$("[placeholder]").parents("form").submit(function() {
$(this).find("[placeholder]").each(function() {
var input = $(this);
if (input.val() == input.attr("placeholder")) {
input.val("");
}
})
});
});
</script>
</head>
<body>
<input type="text" value="" placeholder="介绍一下你自己,比如你的职业、公司,或专业特长、兴趣爱好等。"/>
<input type="text" value="" placeholder="介绍一下你自己,"/>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script type="text/javascript" language="javascript" src="Js/jquery.js"></script>
<script type="text/javascript" language="javascript">
$(function(){
$("[placeholder]").css("color","#ccc")
$("[placeholder]").focus(function() {
var input = $(this);
if (input.val() == input.attr("placeholder")) {
input.val("");
input.removeClass("placeholder");
}
}).blur(function() {
var input = $(this);
if (input.val() == "" || input.val() == input.attr("placeholder")) {
input.addClass("placeholder");
input.val(input.attr("placeholder"));
}
}).blur();
$("[placeholder]").parents("form").submit(function() {
$(this).find("[placeholder]").each(function() {
var input = $(this);
if (input.val() == input.attr("placeholder")) {
input.val("");
}
})
});
});
</script>
</head>
<body>
<input type="text" value="" placeholder="介绍一下你自己,比如你的职业、公司,或专业特长、兴趣爱好等。"/>
<input type="text" value="" placeholder="介绍一下你自己,"/>
</body>
</html>
相关文章推荐
- jQuery实现TEXT文本框输入时的提示信息(谷歌百度淘宝搜索框提示实现)
- jquery 文本框失去焦点显示提示信息&&单击置空文本框
- Java JQuery 对空文本框进行信息提示
- jQuery实现input文本框内灰色提示文本效果 和 input标签获取焦点是文本框内提示信息清空
- jquery实现文本框闪烁提示用户验证信息
- 【转】jquery实现文本框有提示输入的信息
- jquery文本框内提示信息插件——SmokeScreen
- jquery地图(map)热点提示信息
- jquery 的uploadify上传时出错信息提示成中文!比如文件大小限制提示错误File size:Error
- jQuery地图热点效果-鼠标经过弹出提示层信息
- jQuery简单实现input文本框内灰色提示文本效果的方法
- jquery信息提示框——clueTip的应用
- jQuery-easyui将validatebox提示信息改为中文
- jquery 消息提示美化 非阻塞式 信息/消息提示框
- js监听文本框输入字数,字数超出限定个数则提示信息变红
- jquery当鼠标移动到button按钮控件时,会出现提示信息
- Jquery中国地图热点效果-鼠标经过弹出提示层信息的简单实例
- qTip2 精致的jQuery提示信息插件
- jquery validate提示错误信息位置修改
- 不错的JQuery屏幕居中提示信息封装,使用方便,可集成到项目