键盘输入实时显示搜索结果数据,需要用到input监听文本框输入的值,然后请求后端数据,以下个简单的方法,共大家参考。
<!DOCTYPE html>
<html>
<head>
         <meta charset="UTF-8">
         <title>Document</title>
         <script src="https://libs.baidu.com/jquery/2.1.1/jquery.min.js"></script>
</head>
<body>
<style>
         .pop{ display: none;}
</style>
         <input type="text" name="input" id="input">
         <div>不能为空</div>
         <script>
                   $('#input').on("input",function(){
     console.log($(this).val().length);//打印输入框字符长度
                            if($(this).val().length == 0){
                                      $(".pop").show().delay(5000).hide(100);
                            }else{
                                     // 请求数据
                            }
                   });
         </script>
</body>
</html> 
               
                 
                           
                           
                         
                         
                         
                         
                         
                         
                         
                         
                
                 
                         
                         
                         
                         
                 关于简忆
关于简忆 简忆诞生的故事
简忆诞生的故事 
            


 粤ICP备16092285号
粤ICP备16092285号
文章评论(0)