zoukankan      html  css  js  c++  java
  • HTML输入框

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
        <style>
            .g{
                color: lightgray;
            }
            .b{
                color: #000;
            }
        </style>
    </head>
    <body>
        <input type="text" placeholder="请输入内容"/>
        <!--不是每个浏览器都支持这个-->
        <p>当鼠标进入时,移除内容 /n
            当鼠标退出时,添加内容</p>
        <input type="text" class="g" value="请输入内容" onfocus="Focus(this);" onblur="Blur(this)" />
        <script>
            function Focus(arg){
                arg.className="b"
                var current_val= arg.value;
                console.log(current_val)
                if(current_val=='请输入内容'){
                    arg.value="";
                }
            }
            function Blur(arg) {
                var current_val= arg.value;
                if(current_val=='请输入内容'||current_val.trim().length==0){
                    arg.value='请输入内容'
                    arg.className='g'
                }
            }
        </script>
    </body>
    </html>
  • 相关阅读:
    Noip2017 提高组初赛 游(baozha)记
    bzoj4557
    MVVM
    当下较热web前端技术汇总
    JQ 常见demo
    各种宽高
    JQuery 总结
    自定义滚动条配合鼠标滚轮demo
    H5 触摸事件
    SQL必备知识点
  • 原文地址:https://www.cnblogs.com/ezway/p/7028179.html
Copyright © 2011-2022 走看看