在我们开发过程中特别是用户注册时会有一个效果,就是文本框获取焦点清空提示,如果用户没有输入信息失去焦点赋值上我们的提示语。
<html>
<head>
<meta http-equiv=
"content-type"
content=
"text/html; charset=UTF-8"
/>
<script>
$(
function
(){
$(
"#account"
).focus(
function
(){
var
account_value=$(
this
).val();
if
(account_value==
"请输入账号"
){
$(
this
).val(
""
);
}
});
$(
"#account"
).blur(
function
(){
var
account_value=$(
this
).val();
if
(account_value==
""
){
$(
this
).val(
"请输入账号"
);
}
});
});
</script>
</head>
<body>
账号:<input id=
"account"
type=
"text"
value=
"请输入账号"
/>
</body>
</html>