<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<style>
input {
color: gray;
}
</style>
</head>
<body>
<input type="text" value="请输入搜索内容" id="tex"/>
<script src="common.js"></script>
<script>
//注册获取焦点事件
my$("tex").onfocus = function () {
if (this.value == "请输入搜索内容") {
this.value = "";//清空文本框
this.style.color = "black";
}
};
//注册失去焦点事件
my$("tex").onblur = function () {
if (this.value == "") {
this.value = "请输入搜索内容";
this.style.color = "gray";
}
};
</script>
</body>
</html>