TypeError:jQuery.browser未定义

我正在使用jquery mobile 1.4.2和脚本1.11.0

我之前已经阅读过有关此问题的问题,但我没有在我的代码中使用该方法。

这是我的代码

脚本

jQuery("input[name^='cat']").bind(jQuery.browser.msie ? 'click' : 'change', function(event) { var id = jQuery(this).attr('id'); mantener_seleccion(id);//its a function name }); 

如果我运行它的显示错误像这样“TypeError:jQuery.browser未定义”请任何人帮我这个。

jQuery.browser已弃用。 在jQuery 1.9中删除了此属性

演示

使用navigation.userAgent

 if(navigator.userAgent.toUpperCase().indexOf('MSIE') >= 0){ alert("IE") } 

使用此代码段:

 var isIE = navigator.userAgent.toUpperCase().indexOf('MSIE') >=0 ? 'click' : 'change' ; jQuery("input[name^='cat']").bind(isIE , function(event) { var id = jQuery(this).attr('id'); mantener_seleccion(id);//its a function name }); 

只需在我的代码中添加以下脚本即可。

  

请参阅此链接以获取更多信息。 https://github.com/Studio-42/elFinder/issues/469

Ankur Modi的回答是可行的,但是我将为你正在通过安全连接工作的用例添加一个。

浏览器将通过安全连接过滤出混合内容,因此您需要手动导入JS migrate 1.0.0并进行安装。 在我的用例中,我们使用ASP.Net MVC 5x和旧版JS小部件的混搭。

  1. 使用NuGet包管理器安装JS migrate。 我安装了1.0.0,因为这解决了我的问题。 较新的版本没有解决我的具体问题。
  2. 在BundleConfig.cs中添加以下行:

      bundles.Add(new ScriptBundle("~/bundles/jqmigrate").Include( "~/Scripts/jquery-migrate-1.0.0.js")); 
  3. 在_Layout.cshtml中,将以下行添加到’Scripts.Render’部分的底部:

     @Scripts.Render("~/bundles/jqmigrate") 

    您现在应该不再收到错误。