您的位置:首页 > 其它

表单事件,onblur,onfocus,焦点

2016-04-15 10:43 423 查看
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>表单事件</title>
<script type="text/javascript">
//表单焦点失去、获得
onload = function () {
var txt = document.getElementById("txt");
txt.onblur = function () {
if (txt.value == "") {
txt.value = "如123abc@163.com";
}
}
txt.onfocus = function () {
if (txt.value == "如123abc@163.com") {
txt.value = "";
}
}
}
</script>
</head>
<body>
<form id="fm">
<!--有时提交会出现405错误,可能与name,value,id有关-->
<input type="text" name="uid" value="" id="txt" /><br />
<input type="password" name="pwd" value="" /><br />
<input type="submit" value="提交" id="btn1" /><br />
</form>

</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: