JavaScript搜索栏
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<style>
input {
color: #999999;
}
</style>
</head>
<body>
<input type="text" value="请输入搜索内容" id="text"/>
<script>
document.getElementById("text").onfocus = function () {
if (this.value == "请输入搜索内容") {
this.value = "";
this.style.color = "#3c3c3c";
}
};
document.getElementById("text").onblur = function () {
if (this.value.length == 0) {
this.value = "请输入搜索内容";
this.style.color = "#999999";
}
};
</script>
</body>
</html>