views:

237

answers:

2

I'm having some IE7 (and presumably IE6) issues with the script.

<script type="text/javascript">
$(document).ready(function(){
    $(".testimonial:first").show();
    $("li.testID:first").addClass("selectedName");

    $("li.testID").click(function(){
     $("li.testID").removeClass("selectedName");
     $(this).addClass("selectedName");
        $(".testimonial").hide();
        $(this).next(".testimonial").css({
                zIndex:'9999',
                }).fadeIn("slow");
    });
});
</script>

It's meant to add a selectedName class to the first item in the list (basically makes it bold) and shows the corresponding div with the class "testimonial". Then once you click on another one it adds the class and reloads the div.

Works fine in FF and Safari but I get nothing in IE7, it doesnt swap the first class on document ready nor does it swap anything on click.

Any ideas??

Thanks!

+3  A: 

From this piece of code:

$(this).next(".testimonial").css({
            zIndex:'9999',
}).fadeIn("slow");

I'm pretty sure IE chokes on that comma at the end:

            zIndex:'9999',

Remove the comma, see if it works like that.


To expand on my answer, I'm 99.99% sure IE doesn't tolerate a comma before a closed square bracket. I don't remember if it does tolerate one right before closing a curly bracket but it's worth a shot.

Kaze no Koe
or change it to a semicolon which was probably intended
NickLarsen
Wow, sorry I really should have noticed that. Definitely fixed the problem thanks!
askon
I think he probably had something else under it, he removed it and forgot to remove the comma as well. I don't think a semicolon would be correct because it's an object literal: {one: '1', two: '2'}is correct, while: {one: '1'; two: '2'}would be wrong since *one: '1'* is not an instruction.
Kaze no Koe
You're welcome, this bugger used to get me all the time so now I zero in on it pretty easily :) Notice that your syntax is actually correct, this is one of those annoying IE-only bugs.
Kaze no Koe
A: 

Hi,

Here's my code which works fine in FF but not IE7.

$(document).ready(function(){

$("#t_images").click(function () { $("#t_essentials").removeClass("active"); $("#t_basics").removeClass("active"); $("#t_additional").removeClass("active"); $("#t_destinations").removeClass("active"); $("#t_marketing").removeClass("active"); $("#t_images").addClass("active");

   $("#t_essentials1").addClass("hideme");
  $("#t_basics1").addClass("hideme");
  $("#t_additional1").addClass("hideme");
  $("#t_destinations1").addClass("hideme");
  $("#t_marketing1").addClass("hideme");
  $("#t_images1").removeClass("hideme");
});

}

SHUBU