DEfusion
DEfusion

Reputation: 5613

Why isn't jQuery $('.classname') working in IE?

With valid HTML the following finds the object as expected in all browsers but gets NULL in IE (6 & 7).

$(document).ready(function() {
    alert( '$(.rollover):\n' + $('.rollover'));
});

I've tried by switching it to something simpler like $('a') but I always get NULL in IE.

Update: After running the page through the W3C validator (and ignoring what my Firefox validator plugin was telling me) it appears there are actually quite a lot of validation errors (even with HTML 4 Transitional defined), which I can't easily fix, so my guess is that is the cause of my issues. As trying on a very simple document works as expected in IE.

Upvotes: 0

Views: 1321

Answers (3)

Steve Davis
Steve Davis

Reputation: 716

If you're having $ conflicts there are many way to avoid this as documented here.

Upvotes: 1

DEfusion
DEfusion

Reputation: 5613

It seems that it is AjaxCFC's JavaScript includes that are causing a problem, more specifically the ajaxCFC util.js which seems to define it's own $.

Moving those includes before that of the JQuery lib fixed the above issues I was having.

Upvotes: 1

Adam Bellaire
Adam Bellaire

Reputation: 110489

I think we'd have to see the HTML. I've never had a problem with class selection in jQuery/IE. You should get [object Object] for the jQuery object in the alert. Also, are you using an old version of jQuery?

Upvotes: 0

Related Questions