<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        <input type="text" name="username" id="username" value="" />
        
    <!--<h1></h1>-->
    <script type="text/javascript">
            var inputUser = document.querySelector('#username')
//            var h1 = document.querySelector('h1')
//            //输入事件,一般用于检验输入的数据是否符合规范
            inputUser.oninput = function(e){
                console.log(e)
                if(e.target.value == 'admin'){
                    e.target.style.background = 'skyblue'
                }else{
                    e.target.style.background = 'pink'
                }
//                h1.innerHTML = e.target.value
            }
            
        </script>
    </body>
</html>

 

相关文章:

  • 2022-12-23
  • 2022-01-15
  • 2021-11-07
  • 2022-12-23
  • 2021-11-09
  • 2021-11-11
猜你喜欢
  • 2021-04-02
  • 2021-12-18
  • 2022-12-23
  • 2022-03-08
  • 2022-12-23
  • 2021-08-29
相关资源
相似解决方案