如何使用jQuery Migrate插件 [英] How to use jQuery Migrate plugin
问题描述
我正在使用jquery 2.0,但也希望使用jQuery migration插件,以便我的网站可以在较旧的浏览器上运行.但是,我一直无法使其正常工作.我在html的标题部分中具有以下内容.
I'm using jquery 2.0 but would like to also use the jQuery migrate plugin so my website will work on older browsers. However, I've been unsuccessful at getting it to work. I have the following in the header section in my html.
<head>
<meta http-equiv="X-UA-Compatible" content="IE=8" />
<script src="/Scripts/jquery-2.0.3.js"></script>
<script src="/Scripts/jquery.unobtrusive-ajax.min.js"></script>
<script src="/Scripts/jquery.validate.min.js"></script>
<script src="/Scripts/jquery.validate.unobtrusive.min.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
</head>
兼容性元标记是,因此我可以在我的计算机(具有IE 11)上对其进行测试.我没有装有旧版IE的计算机.无论如何,这会给我带来JavaScript错误,例如:
The compatibility meta tag is so I can test this on my computer (which has IE 11). I don't have a computer with an older IE. Anyway, this is giving me javascript errors such as:
0x800a01b6-JavaScript运行时错误:对象不支持属性 或方法'addEventListener'
0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'addEventListener'
jQuery迁移指南( https://github.com/jquery/jquery-migrate/)似乎只是说在包括jQuery之后包括了migration插件.我在做什么错了?
The jQuery migrate guide (https://github.com/jquery/jquery-migrate/) seems to just say to include the migrate plugin after including jQuery. What am I doing wrong?
编辑
我发现我的本地jquery.js文件必须损坏,或者我从其中获取的nuget软件包的版本错误.由于当我直接从code.jquery.com包含jquery时,该错误消失了.
I found my local jquery.js file must be corrupt or maybe the nuget package I got it from has a bad version of it. Since that error goes away when I include jquery directly from code.jquery.com.
<head>
<meta http-equiv="X-UA-Compatible" content="IE=8" />
<script src="http://code.jquery.com/jquery-2.1.0.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
</head>
但是,我的脚本给出了一个错误.这是一个示例脚本
However, my scripts give an error. Here's an example script
function HighlightSelectedRow(tr) {
$("#TableSummary tr").removeClass("HighlightedRow");
tr.className += " HighlightedRow";
}
出现以下错误
0x800a138f - JavaScript runtime error: The value of the property '$' is null or undefined, not a Function object
谢谢
推荐答案
也许您应该重新排序js堆栈:
May be you should reorder the js stack:
<head>
<meta http-equiv="X-UA-Compatible" content="IE=8" />
<script src="/Scripts/jquery-2.0.3.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script src="/Scripts/jquery.unobtrusive-ajax.min.js"></script>
<script src="/Scripts/jquery.validate.min.js"></script>
<script src="/Scripts/jquery.validate.unobtrusive.min.js"></script>
</head>
这篇关于如何使用jQuery Migrate插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!