zoukankan      html  css  js  c++  java
  • 学习一个输入框提示列表效果

    学习一个输入框提示列表效果记录下

    主要要点:li列背景换行变色

    .Menu2 ul{margin:0;padding:0}
    .Menu2 ul li
    {width:100%;height:25px;line-height:25px;text-indent:15px;
                 border-bottom
    :1px dashed #ccc;color:#666;cursor:pointer;
     change
    :expression(
      this.onmouseover=function(){
        this.style.background="#F2F5EF"
    ;
      
    },
      this.onmouseout=function()
    {
        this.style.background="";
      
    }
     )
    }

    主要js代码

    <script type="text/javascript">
    function showAndHid(obj,types)
    {
      
    var Layer=window.document.getElementById()
    }
      
    function showAndHide(obj,types){
        
    var Layer=window.document.getElementById(obj);
        
    switch(types){
      
    case "show":
        Layer.style.display
    ="block";
      
    break;
      
    case "hide":
        Layer.style.display
    ="none";
      
    break;
    }
      }
      
    function getValue(obj,str){
        
    var input=window.document.getElementById(obj);
    input.value
    =str;
      }
    </script>

    body里调用

    <div> Location:<input type="text" id="txt" name="txt" onfocus="showAndHide('List1','show');" onblur="showAndHide('List1','hide');"></div>
       
    <!--列表1-->
       
    <div class="Menu" id="List1">
      
    <div class="Menu2">
        
    <ul>
      
    <li onmousedown="getValue('txt','中国CHINA');showAndHide('List1','hide');">中国CHINA</li>
      
    <li onmousedown="getValue('txt','美国USA');showAndHide('List1','hide');">美国USA</li>
    </ul>
      
    </div>
       
    </div>

    全部例子代码:下载 

  • 相关阅读:
    Asp.Net多线程用法1
    Asp.Net操作FTP方法
    django 利用PIL 保存图片
    django —— Celery实现异步和定时任务
    豆瓣源安装requirements.txt
    一个有趣的python排序模块:bisect
    Python 多线程
    python list元素为dict时的排序
    python版本坑:md5例子(python2与python3中md5区别)
    单独的 python 脚本文件使用 django 自带的 model
  • 原文地址:https://www.cnblogs.com/sendling/p/1372191.html
Copyright © 2011-2022 走看看