输入框焦点时自动清除value

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript" src="jquery-1.9.1.js" ></script>
<script type="text/javascript">
$(function(){
$('#address').focus(function(){
$(this).val()==this.defaultValue?$(this).val(''):'';
});
$('#address').blur(function(){
$(this).val()==''?$(this).val(this.defaultValue):'';
});
})
</script>
<title></title>
</head>
<body>
<input type="text" id="address" value="请输入邮箱地址" />
</body>
</html>

posted @ 2015-08-24 09:19  放荡不羁的春天  阅读(369)  评论(0编辑  收藏  举报