jQuery 隐藏和显示 input 默认值示例
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "https://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="https://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>jquery+javascript 实现 table 的增加和减少</title>
<script language="javascript" src="jquery-1.7.1.min.js"></script>
</head>
<body>
<p><input type="text" value="请输入邮箱地址" id="email" id="email" /></p>
<p><input type="button" value="提交" /></p>
<script type="text/javascript">
$("#email").focus(function(){
var email_txt = $(this).val();
if (email_txt == this.defaultvalue) {
$(this).val("");
}
})
$("#email").blur(function(){
var email_txt = $(this).val();
if (email_txt == "") {
$(this).val(this.defaultvalue);
}
})
</script>
</body>
</html>
效果预览: