Why document.ready doesn't fire in IE 7

Why document.ready doesn't fire in IE 7

This is actually a fix for a fault that was troubling me for a while - I thought it might help others if I post it. It seems really simple but I have searched and can't find any reference to it.

When you import the JQuery file in your page you might think you could do it like this:

<script src="jquery-1.3.1.min.js" type="text/javascript" />


or like this:

<script src="jquery-1.3.1.min.js" type="text/javascript"></script>


and it wouldn't make any difference. But in IE you must use the second form (using </script>) not the first one, otherwise document.ready doesn't fire. Opera will accept either form.

This seems to apply to both HTML and XHTML and it's when you are working off the local file system and opening the HTML file directly in a browser. I haven't tried it off a web server yet.

Anyway the bottom line is always use "</script>" to close off the tag, not "/>".

Hope this helps anyone else who gets confused about this