html 搜索框

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
       <div style="width: 600px;margin: 0 auto;">
           <input  id="i1" onfocus="Focus()" onblur="Onblur()" type="text" value="请输入关键字">

           <input  type="text" placeholder="请输入关键字">
       </div>
       <script>
           function Focus() {
               var tag =document.getElementById("i1")
               var val=tag.value
               if (val=="请输入关键字"){
                   tag.value=""
               }
           }
           function Onblur() {
               var tag =document.getElementById("i1")
               var val=tag.value
               if (val==""){
                   tag.value="请输入关键字"
               }
           }
       </script>
</body>
</html>
展开阅读全文

没有更多推荐了,返回首页