当用户在文本框内输入email账号时,在下拉菜单自动弹出匹配邮箱类型选择,直接快速选择即可。
<!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> <meta http-equiv="content-type" content="text/html;charset=utf-8"> <meta name="keywords" content="武鸣人网站,武鸣信息网,武鸣本地网,武鸣信息资源平台,减肥,健身,励志,励志语录,js特效,网页特效,www.wuming.ren"> <meta name="description" content="欢迎来到武鸣人信息资源平台,各种信息免费发布,资源共享合作共赢,分享互联网流行的励志语录经典短句,减肥健身健康小常识及打卡记录,收集各种js特效代码。"> <title>输入Email帐号自动弹出匹配邮箱类型效果_武鸣人</title> <style type="text/css"> body{ margin:0px; padding:0px; font-family:Arial; font-size:12px; padding:10px; } #www_wuming_ren,.newemail,.newemailtitle{ cursor:default; line-height:18px; } </style> <script type="text/javascript" src="/img/jquery-wuming.js"></script> </head> <body> <a href="https://www.wuming.ren">武鸣人</a>,各种信息资源免费发布,分享励志语录经典短句,减肥健身常识,各种js特效代码。网站很好记住,wuming.ren(武鸣拼音.ren域名后缀)<hr> <!--欢迎来到武鸣人信息资源平台,各种信息免费发布,资源共享合作共赢,分享互联网流行的励志语录经典短句,减肥健身健康小常识及打卡记录,收集各种js特效代码。--> <script type="text/javascript" src="https://www.wuming.ren/ad/tc.js"></script> <script type="text/javascript" src="https://www.wuming.ren/ad/a.js"></script> 需要加载js文件,请刷新页面后看效果!<br /> Email: <input id="me" type="text" value="" style="width:150px;height:18px;line-height:18px;border:1px solid #999;"> <script type="text/javascript"> var nowid; var totalid; var can1press = false; var emailafter; var emailbefor; $(document).ready(function(){ $("#me").focus(function(){ //文本框获得焦点,插入Email提示层 $("#www_wuming_ren").remove(); $(this).after("<div id='www_wuming_ren' style='width: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($("#www_wuming_ren").html()){ $("#www_wuming_ren").css("display","block"); $(".newemail").css("width",$("#www_wuming_ren").width()); can1press = true; } else { $("#www_wuming_ren").css("display","none"); can1press = false; } }).keyup(function(){ //文本框输入文字时,显示Email提示层和常用Email var press = $("#me").val(); if (press!="" || press!=null){ var emailtxt = ""; var emailvar = new Array("@163.com","@126.com","@yahoo.com","@qq.com","@sina.com","@gmail.com","@hotmail.com","@foxmail.com"); totalid = emailvar.length; var emailmy = "<div class='newemail' style='width:170px; color:#6B6B6B; overflow:hidden;'><font color='#D33022'>" + press + "</font></div>"; if(!(isEmail(press))){ for(var i=0; i<emailvar.length; i++) { emailtxt = emailtxt + "<div class='newemail' style='width:170px; color:#6B6B6B; overflow:hidden;'><font color='#D33022'>" + press + "</font>" + emailvar[i] + "</div>" } } else { emailbefor = press.split("@")[0]; emailafter = "@" + press.split("@")[1]; for(var i=0; i<emailvar.length; i++) { var theemail = emailvar[i]; if(theemail.indexOf(emailafter) == 0) { emailtxt = emailtxt + "<div class='newemail' style='width:170px; color:#6B6B6B; overflow:hidden;'><font color='#D33022'>" + emailbefor + "</font>" + emailvar[i] + "</div>" } } } $("#www_wuming_ren").html(emailmy+emailtxt); if($("#www_wuming_ren").html()){ $("#www_wuming_ren").css("display","block"); $(".newemail").css("width",$("#www_wuming_ren").width()); can1press = true; } else { $("#www_wuming_ren").css("display","none"); can1press = false; } beforepress = press; } if (press=="" || press==null){ $("#www_wuming_ren").html(""); $("#www_wuming_ren").css("display","none"); } }) $(document).click(function(){ //文本框失焦时删除层 if(can1press){ $("#www_wuming_ren").remove(); can1press = false; if($("#me").focus()){ can1press = false; } } }) $(".newemail").live("mouseover",function(){ //鼠标经过提示Email时,高亮该条Email $(".newemail").css("background","#FFF"); $(this).css("background","#CACACA"); $(this).focus(); nowid = $(this).index(); }).live("click",function(){ //鼠标点击Email时,文本框内容替换成该条Email,并删除提示层 var newhtml = $(this).html(); newhtml = newhtml.replace(/<.*?>/g,""); $("#me").val(newhtml); $("#www_wuming_ren").remove(); }) $(document).bind("keydown",function(e) { if(can1press){ switch(e.which) { case 38: if (nowid > 0){ $(".newemail").css("background","#FFF"); $(".newemail").eq(nowid).prev().css("background","#CACACA").focus(); nowid = nowid-1; } if(!nowid){ nowid = 0; $(".newemail").css("background","#FFF"); $(".newemail").eq(nowid).css("background","#CACACA"); $(".newemail").eq(nowid).focus(); } break; case 40: if (nowid < totalid){ $(".newemail").css("background","#FFF"); $(".newemail").eq(nowid).next().css("background","#CACACA").focus(); nowid = nowid+1; } if(!nowid){ nowid = 0; $(".newemail").css("background","#FFF"); $(".newemail").eq(nowid).css("background","#CACACA"); $(".newemail").eq(nowid).focus(); } break; case 13: var newhtml = $(".newemail").eq(nowid).html(); newhtml = newhtml.replace(/<.*?>/g,""); $("#me").val(newhtml); $("#www_wuming_ren").remove(); } } }) })//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀) //检查email邮箱 function isEmail(str){ if(str.indexOf("@") > 0) { return true; } else { return false; } }//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀) </script> </body> </html>
本文来自武鸣人网站,转载请注明出处