input

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <style type="text/css">
            input{
                width: 200px;
                height: 20px;
                font-size: 16px;
                font-family: "微软雅黑";
                margin-left: 5px;
                padding: 5px;
                background-image: url(browse1.png);
                background-repeat: no-repeat;
                background-position-x: 5px;
                background-position-y: center;
            }
            input[type="text"]:focus{
                background-image: none;
            }
            
        </style>
    </head>
    <body>
        <input type="text" name="" id="aaa" value="" onchange="aa()"/>
        <script type="text/javascript">
            function aa(){
                if (document.getElementById('aaa').value) {
                    document.getElementById('aaa').style.backgroundImage = "url("+")";
                }else{
                    document.getElementById('aaa').style.backgroundImage = "url(browse1.png"+")";
                }
            }
        </script>
    </body>
</html>
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容