jquery中获得与失去焦点的案例

<html>
<head>
<meta charset="utf-8"/>
<script type="text/javascript" src="script/jquery-1.4.2.min.js"></script>
<script>
$(function(){
//在jquery中如果操作的是同一个对象,规范建议换行
$("#username").focus(function)(){
$(this).val("")
.blur(function(){
$(this).val("请输入用户名");
});
});
</script>
</head>
<body>
<input type="text" id="username" value="请输入用户名"/>
<input type="text" id="email" value="请输入邮箱"/>
</body>
</html>

posted @ 2013-03-28 21:38  xinyuyuanm  阅读(203)  评论(0编辑  收藏  举报