模拟搜索框
效果展示
代码图片
复制如下
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
input{
color: #999;
}
</style>
</head>
<body>
<input type="text" value="手机" id="txt">
</body>
<script type="text/javascript">
document.getElementById('txt').onfocus=function(){
if(this.value=="手机"){
this.value="";
this.style.color="#333";
}
};
document.getElementById('txt').onfocus=function(){
if(this.value==""){
this.value="手机";
this.style.color="#999";
}
}
</script>
</html>