<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="js/jquery-1.8.3.js"></script>
</head>
<body>
账号:<input type="text" value="请输入账号" name="请输入账号" />
密码:<input type="password" value="请输入密码" name="请输入密码" />
</body>
<script type="text/javascript">
$("input[type=‘text‘]").on("focus blur",function(){
//判断是否获取焦点
if($(this).is(":focus")){
$(this).val("");
}else{//否还原内容
if($(this).val().length==0){
//获取属性,使用attr()
//设置属性 attr("key","value")
//获取属性 attr("key")
$(this).val($(this).attr("name"));
}
}
});
</script>
</html>