2
votes

I am having problems getting jquery to work in internet explorer 9 while working on local computer (wamp). Everything works in Firefox and Chrome. With internet explorer, nothing happens unless I hit "F12" to open developer tools. Then if I refresh the page, everything works. I'm not seeing any errors in IE either before or after opening developer tools.

I am trying to work through problems in the book Drupal 6 Javascript and JQuery. I first noticed that the examples in the book weren't working in IE. I am now trying to get this simple jquery script to execute (which is located in a file test.js):

$(document).ready(function(){
$('.title').append('<p>test</p>');
});

Again, this works in Firefox and Chrome, but not IE9, unless developer tools is open and the page is refreshed.

Any suggestions?

Edit: Problem solved. I will still including the jquery from the book, which contained "console.log("FOO");". Commenting this out solved the issue.

2

2 Answers

1
votes

In my page, if I comment the 'console.log' statements, it will load correctly. My guess is that the console doesn't exist unless you hit 'F12' but when you hit 'F12' it does exist. Try removing all debug statements, and see if it works.

0
votes

I had this happen to me two nights ago. It would only work after I opened F12 Developer tools, even if I had closed the tools. Nothing about your code looks syntactically incorrect.

More likely, the .ready() event is not firing because your DOM isn't fully loading properly. Without more information it's hard to know what could be doing it.