• 仿造email后缀搜索功能(2)


    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>输入Email相关字符自动提示Email地址</title>
    <script src="js/jquery.min.js" type="text/javascript"></script>
    <style type="text/css">
    body
    {
    margin:0px;
    padding:0px;
    font-family:Arial;
    font-size:12px;
    padding:10px;
    }
    </style>
    </head>
    <body>
    Email <input id="me" type="text" value="" style="150px; height:18px; line-height:18px; border:1px solid #999;">
    <script type="text/javascript">
    var can1press = false;
    $(function(){
    $("#me").focus(function(){ //文本框获得焦点,插入Email提示层
    $("#myemail").remove();
    $(this).after("<div id='myemail' style='170px; height:auto; background:#fff; color:#6B6B6B; position:absolute; left:"+$(this).get(0).offsetLeft+"px; top:"+($(this).get(0).offsetTop+$(this).height()+2)+"px; border:1px solid #ccc;z-index:5px; '></div>");
    if($("#me").html()){
    $("#myemail").css("display","block");
    $(".newemail").css("width",$("#myemail").width());
    can1press = true;
    } else {
    $("#myemail").css("display","none");
    can1press = false;
    }
    }).keyup(function(){ //文本框输入文字时,显示Email提示层和常用Email
    var press = $("#me").val();
    if (press!="" || press!=null){
    var emailtxt = "";
    var emailvar = ["用户名","部门名称","真实姓名"];
    for(var i=0; i<emailvar.length; i++) {
    emailtxt = emailtxt + "<div class='newemail' onclick='getT("+ i +")' style='170px; color:#6B6B6B; overflow:hidden;'><span color='#D33022'>" + press + "</span>" + emailvar[i] + "</div>"
    }
    $("#myemail").html(emailtxt);
    if($("#myemail").html()){
    $("#myemail").css("display","block");
    $(".newemail").css("width",$("#myemail").width());
    can1press = true;
    } else {
    $("#myemail").css("display","none");
    can1press = false;
    }
    //beforepress = press;
    }
    if (press=="" || press==null){
    $("#myemail").html("");
    $("#myemail").css("display","none");
    }
    })
    $(document).click(function(){ //文本框失焦时删除层
    if(can1press){
    $("#myemail").remove();
    can1press = false;
    if($("#me").focus()){
    can1press = false;
    }
    }
    })
    })
    function getT(obj) {
    console.log(855);
    console.log(obj);
    }
    </script>
    </body>
    </html>
  • 相关阅读:
    垂直margin为什么会重叠
    forEach()和for/in循环的缺点与for-of循环
    使用CleanWebpackPlugin插件报错原因:CleanWebpackPlugin is not a constructor
    Vue中常用的组件库
    Vue中使用keep-alive优化网页性能
    Vue中router路由异步加载组件-优化性能
    面试题-JS中的作用域相关问题
    JS中的垃圾回收机制
    【转】 SpringMVC详解(三)------基于注解的入门实例
    【转】 SpringMVC详解(二)------详细架构
  • 原文地址:https://www.cnblogs.com/cx709452428/p/7010290.html
Copyright © 2020-2023  润新知