rusbi
rusbi

Reputation: 540

jQuery not working at all in IE 8

I written some stuff using jQuery and it works great in Chrome. When I tried to open in in IE it looked like jQuery wasn't loaded at all... Now I tried the simplest possible jQuery demo and it still doesn't work...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <script type="text/javascript" src="jquery-1.4.2.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
        $("a").click(function(e){
            (e.preventDefault();
            $(this).hide("slow").show("fast");
        });   
    });


    </script>
  </head>
  <body>
    <a href="http://jquery.com/">jQuery</a>
  </body>
</html>

The page should hide, then show the link but it just link to the jQuery website when I open it in IE. It works normally in Chrome....

Upvotes: 0

Views: 291

Answers (5)

Vivek
Vivek

Reputation: 11028

remove extra ( you have written before e.preventDefault();

Upvotes: 0

Tom
Tom

Reputation: 12988

Replace this...

$(this).hide("slow").show("fast");

with this...

$(this).hide("slow", function () {
    $(this).show("fast")
});

I've not tested this by the way.

Upvotes: 0

rusbi
rusbi

Reputation: 540

There was an error in code... and extra (. It seems that this didn't bother Chrome...

Upvotes: 0

Olical
Olical

Reputation: 41352

Try adding a doctype such as this to the top of the page. jQuery will not work when the browser is in quirks mode.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Upvotes: 2

Jamiec
Jamiec

Reputation: 136074

event is a keyword in IE, try changing that parameter to simply e or evt.

Edit: Saying that, this jsFiddle is working fine for me in FF, Chrome and IE.

Upvotes: 2

Related Questions