I have the following sample html file:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Example</title>
<script src="../Scripts/jquery-2.0.3.js"></script>
<!--<script src="../Scripts/jquery-1.7.js"></script>-->
<script type="text/javascript">
$(document).ready(function () {
$('#mainheader').css("color", "red");
});
</script>
</head>
<body>
<h1 id="mainheader" class="header">Sample 1</h1>
<h2 class="header info">Sample 2</h2>
<h3 class="info">Sample 3</h3>
</body>
</html>
When i run the same with jQuery version 2.0.3, it runs into error:
Unhandled exception at line 834, column 4 in /Scripts/jquery-2.0.3.js
0x800a01b6 - Microsoft JScript runtime error: Object doesn't support this property or method
At the line: // Use the handy event callback document.addEventListener( "DOMContentLoaded", completed, false );
But if I run with a lower version of it i.e., 1.7, it works fine...
However the above code works perfectly fine for both versions on Chrome.
Can you please help me out with the differences:
Thanks & Regards.
At the moment jQuery 2.x " does not support Internet Explorer 6, 7, or 8"
Since no one's mentioned it (and it was called out in the comments), here's another possible way of resolving this. This is actually how I'd recommend you roll out your compatibility failsafe, and how I perform it on my projects.
As many have already mentioned, jQuery 2.x drops support for IE8 and below (with a lot of the major changes stemming back from 1.9 even). The reason for the drop being the goal of a smaller overall file size, and faster performance.
That being said, the ideal goal for an application would be to use jQuery 2.x for supported browsers, while offering compatibility for browsers that aren't.
So what I recommend is to just use the jQuery 2.x file (that's what you're supposed to be using anyway, if you're thinking about the future for your application). Not much needed here; just add in your jQuery as before.
<!-- according to h5bp -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/vendor/jquery-2.0.3.min.js"><\/script>')</script>
Then, to ensure compatibility with older IE versions, you can conditionally include the patch file so that it's processed when necessary.
<!--[if lte IE 8]>
<script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<![endif]-->
This ensures you've got a faster, leaner jQuery for supported browsers, and a working jQuery for others, at the cost of what essentially equates to an extra HTTP call (and potentially a larger total bandwidth payload) for when you need the patch.
jQuery 2.x has the same API as jQuery 1.x, but does not support Internet Explorer 6, 7, or 8.
Use the 1.x versions if you need to be compatible with old IE browsers (or recent ones in compatibility mode). The 2.x versions are a branch which removed a lot of stuff whose sole usage was compatibility with those old browsers.
Thats because of the version 2.0.3 does not support IE8 and 1.7 does
jQuery 2+ version does not support IE < 9, if you are planning to support those browsers please stick to the latest 1.x branch version - now 1.10.2
For IE 11 you must have the following in your HTML page
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge;" />
If you have the old html 4.01 doctype tag, it doesn't work.
User contributions licensed under CC BY-SA 3.0