Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JQuery code - Firefox / IE

Status
Not open for further replies.

GezH

Programmer
Aug 7, 2002
68
Hi, I have the following JQuery code which tests for a checkbox:

Code:
if ($("#myBox").is(":checked")){
    // do something
}

It works fine in Firefox, but in IE the debugger throws some kind of "null or not an object" error, and the rest of the script file fails.

"myBox" is the id of the checkbox. Any ideas how I can write this in IE?
 
What's the "do something" bit? That may be where the error lies.

Then again, the IE script debugger throws a fit if someone walks past the window. Try visiting MSN with it turned on.

--
Tek-Tips Forums is Member Supported. Click Here to donate

<honk>*:O)</honk>

Tyres: Mine's a pint of the black stuff.
Mike: You can't drink a pint of Bovril.


 
"myBox" is the id of the checkbox. Any ideas how I can write this in IE?

You could try using normal DOM methods instead of jQuery to see if it works. If it does, then your jQuery syntax is at fault. If it fails, your problem is elsewhere.

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
It really didn't like that syntax. I replaced it with a simple:

Code:
if(document.getElementById('myBox').checked){

..and it's fine now. Now I have a problem with what it's doing inside the block! This code:

Code:
jQuery('div.myDetails').show('slow');

...doesn't work in IE also. After I check the box, I have to actually click in the area of the div for it to display the HTML inside. In FF it just drops down and opens automatically.
 
Ignore this, I'm going to start a new thread, the problem is elsewhere!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top