<html>
<head>
<meta charset="utf-8"/>
</head>
<body>
用户名:<input type="text" id="username" value="请输入用户名" οnfοcus="clearInput()" οnblur="getInput()"/>
密码: <input type="password" id="password"/>
</body>
<script>
function clearInput(){
//获得输入框的值
var username = document.getElementById("username");
username.value = '';
}
function getInput(){
//获得输入框的值
var username = document.getElementById("username");
username.value = '请输入用户名';
}
</script>
</html>