IE is doing strange things with JQuery

Posted by Syncopated on Stack Overflow See other posts from Stack Overflow or by Syncopated
Published on 2010-05-05T11:56:30Z Indexed on 2010/05/05 11:58 UTC
Read the original article Hit count: 118

So ... The thing is, the code works in FireFox, no problems. But when I open the same page, it gives me the following error:

"Undefined is null or not an object."

But when I copy the code to a localhost page, it works fine. Also when I clear my cache in IE it works, but only once, if I refresh after that one load, it gives me the same error.

Here is the code:

<script type="text/javascript" src="datepicker/js/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
     var count3 = 0; 
     var count5 = 0;
     var count2 = 0;
     var count4 = 0;

    $(document).ready(function(){

    $('#switch3').click(function(){
        $('#switchDiv3').slideToggle(350);
            if(count3 == 0){
            count3 = 1;
            document.getElementById('switchImage3').src = "images/ArrowDown.png";
            return;
            } else {
            count3 = 0;
            document.getElementById('switchImage3').src = "images/ArrowRight.png";
            return;
            }
    });

    ... (this is the code for each item that is generated) 
    </script>

And the code that determines the div that should hide:

<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
    <tr>
        <td width="20" align="center" valign="top" style="padding-right: 3px">
            <a style="cursor: pointer;" id="switch3"><img width="20" height="20" src="images/ArrowRight.png" id="switchImage3" style="border-style: solid; border-width: 1px; border-color: black;"/></a>
        </td>
        <td>
            <div id="switchDiv3">
                <div align="left">
                    (Contents of the div here)
                </div>
            </div>
        </td>
    </tr>
</table>

Any help is appreciated!

Thanks in advance

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about internet-explorer