Blogger Information
Blog 35
fans 0
comment 1
visits 42645
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
js仿京东搜索框
魏先生的博客
Original
1356 people have browsed it

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>京东搜索框</title>
        <script src="https://cdn.jsdelivr.net/npm/vue"></script>
    </head>
    <body>
        <div id="demo">
            <input type="text" name="" id="te" value="搜索" />
        </div>
        <script type="text/javascript">
            var inp = document.getElementById('te');
            
            inp.onfocus = function(){
                if(inp.value === '搜索'){
                    this.value = '';
                }
            }
            inp.onblur = function(){
                if(inp.value === ''){
                    this.value = '搜索';
                }
            }
        </script>
    </body>
</html>

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post