html邮箱下拉栏,jquery输入框邮箱下拉智能提示

该博客介绍了在使用高版本jQuery时遇到的$.browser API错误,由于该API在jQuery 1.9后被废除,导致msie属性无法读取。提供了两种解决方案:一是手动填充$.browser对象;二是引入jquery-migrate-1.2.1.js插件。这两种方法都能有效解决因$.browser使用而引发的JavaScript错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

0128d8079591548bfedfab75ab35160b.png

西瓜 0

2015/11/6 13:11:15

此插件,在调用高版本jquery时会出现错误:原因是$.browser这个api从jQuery1.9开始就正式废除,js代码里只要用到$.browser就会报这个错。具体说明参见jQuery官方说明。错误信息:Uncaught TypeError: Cannot read property 'msie' of undefined

解决方法有两种

第1种,在inputmail.js第一行加入jQuery.browser = {}; (function() {

jQuery.browser.msie = false;

jQuery.browser.version = 0;

if (navigator.userAgent.match(/MSIE ([0-9]+)./)) {

jQuery.browser.msie = true;

jQuery.browser.version = RegExp.$1;

}

})();

第2种 在引用用jquery之后在调用jquery-migrate-1.2.1.js即可

回复

在输入邮箱时可以智能提示 <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>jquery输入框邮箱下拉提示层 - </title> <style type="text/css"> *{ margin:0; padding:0;} body { font:12px/1.8 Arial; color:#666;} ul,li{ list-style:none;} h1.tit-h1 { font-size:38px; text-align:center; margin:30px 0 15px; color:#f60;} .go-back{ text-align:center; border-top:1px dashed #ccc; padding:10px; margin-top:20px; font-size:40px;} .wrap{border:1px dashed #ccc; background:#f8f8f8; padding:20px;} .login{width:400px; margin:0 auto; background:#EBEBEB; position:relative;} input{ width:230px; height:28px; margin:10px 0; line-height:28px;} .login .on_changes{width:232px; position:absolute; top:40px; list-style:none; background:#FFF; border:1px solid #000; display:none; padding:10px;} .login .on_changes li{margin:8px;padding:4px;} .login .on_changes li.active{ background:#CEE7FF;} </style> <script type="text/javascript" src="jquery-1.4.4.min.js"></script> <script type="text/javascript" src="inputmail.js"></script> </head> <body> <h1 class="tit-h1">jquery输入框邮箱下拉提示层</h1> <div class="wrap"> <script type="text/javascript"> $(function(){ $("#loginName").changeTips({ divTip:".on_changes" }); }) </script> <div class="login"> <div class="ln">                          <input type="text" maxlength="128" name="loginName" id="loginName" placeholder="邮箱/会员帐号/手机号" /></div> <ul class="on_changes" style="position: absolute; left: 78px; top: 42px"> <li email="">请选择邮箱类型</li> <li email=""></li> <li email="@sina.com"></li> <li email="@163.com"></li> <li email="@qq.com"></li> <li email="@hotmail.com"></li> <li email="@126.com"></li> <li email="@gmail.com"></li> <li email="@yahoo.com"></li> </ul> </div> </div> </div> </body> </html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值