Text Box control

<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>

<input type="text" id="txt" style="color:#CC0000" value="请输入" />
<script type="text/javascript">
window.onload = function() {
var txtOjb = document.getElementById("txt");
txtOjb.onfocus = function() {
if (this.value = "请输入") {
this.value = '';
}
this.style.color = "#000000";
}
txtOjb.onblur = function() {
if (this.value == "") {
this.value = "请输入";
this.style.color = "#CC0000";
}
}
}
</script>
</body>
</html>

Guess you like

Origin www.cnblogs.com/dyf123456/p/11425167.html