• 仿百度搜索的下拉框效果


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
        <title>仿百度搜索的下拉框效果</title>
       <style type="text/css">
        #search_id{font-size:12px; color:#333333}
        #search_id div{ float:left}
        #search_body{ border:1px solid #999999; padding-top:0px; 240px; }
        #search_body input{ height:18px; margin-top:0px;}
        #search_body #searchkey_id{ 238px; border:0px; border-bottom:1px solid #999999;}
        #result_id{ padding-top:0px; 100%;display:none;}
        #result_id table{ 100%; }
        #result_id table tr td:hover{background-color:#FF9999; cursor:pointer }
        </style>
    </head>
    <script type="text/javascript" src="js/jquery-1.3.2.js"></script>
    <script type="text/javascript">

    $(function(){
       var close = true ;
       $("#searchkey_id").keyup(function(){
        var nkey = $.trim($(this).val()) ;
        if("" == nkey || null == nkey){
         $("#result_id").hide() ;
        }
        else {
        //html 为ajax请求 返回的 字符串
         var html = '<table><tr><td>1dfdfdfdf</td></tr><tr><td>12dfdfdf2</td></tr><tr> <td>121212</td></tr></table>'
         $("#result_id").show() ;
         $("#result_id").html(html);
         $("#result_id table tr td").click(function(){
          $("#searchkey_id").val($(this).html()) ;
          $("#result_id").hide() ;
         }).hover(
          function () {
              //$("#searchkey_id").blur(function(){});
           //alert(123) ;
           close = false ;
          },
          function () {
              //$("#searchkey_id").blur(function(){
            //$("#result_id").hide() ;
           //});
           //alert(312) ;
           close = true ;
          }
         ); ;
        }
       }).blur(function(){
        if(close) {
         $("#result_id").hide() ;
        }
       });

       $("#botton_id input").click(function(){
        alert(232323) ;
       });
    });
    </script>

    <body>
    <div id="search_id">
       <div id="search_body">
        <input name="searchkey" type="text" id="searchkey_id" size="30" />
         <div id="result_id">

        
        </div>
       </div>
       <div id="botton_id">&nbsp;<input type="button" value="搜索" /></div>


    </div>


    </body>
    </html>

  • 相关阅读:
    初学:利用mybatis-generator自动生成代码
    数组求和forEach方法
    Node.js热部署代码,实现修改代码后自动重启服务方便实时调试
    nodejs中文乱码问题
    简单说一下SS的原理
    Spring Cloud Eureka 3 (Eureka client注册服务提供者)
    Spring Cloud Eureka 2 (Eureka Server搭建服务注册中心)
    Spring Cloud Eureka 1(eureka简介)
    eclipse中创建多模块maven web项目
    eclipse中创建maven web项目
  • 原文地址:https://www.cnblogs.com/jimmychow/p/2352476.html
Copyright © 2020-2023  润新知