Jquery script issue IE7 add/remove class
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").remove开发者_JS百科Class("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!
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.
精彩评论