zoukankan      html  css  js  c++  java
  • HTML之文本框关键字显示

    文本框默认显示 “请输入关键字”,当鼠标点击输入框的时候, “请输入关键字”这几个字消失,移出文本框又显示出来

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
    </head>
    <body>
        <div style=" 600px;margin: 0 auto;">
            <input id="i1" onfocus="Focus();" onblur="Blur();" 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 Blur(){
                var tag = document.getElementById('i1');
                var val = tag.value;
                if(val.length ==0){
                    tag.value = "请输入关键字";
                }
            }
        </script>
    </body>
    </html>
  • 相关阅读:
    python 线程同步
    python 线程模块
    Python线程
    Python 多线程
    Python SMTP发送邮件
    Python Internet 模块
    简单实例
    Socket 对象(内建)方法
    Python 网络编程
    python 数据库错误处理
  • 原文地址:https://www.cnblogs.com/wspblog/p/6097273.html
Copyright © 2011-2022 走看看