Reputation:
I'm new to JQuery... this code doesn't work in IE7 but does in FF & Chrome. It says its giving me a syntax error, help!
$(function(){ $("#bClose").click(function() { $("#ContactRepeat").slideUp("normal"); });
$("#bContact").click(function() {
if ($("#ContactRepeat").css("display") == "display"){
$("#ContactRepeat").slideToggle("normal", function(){
$("#ContactRepeat").slideToggle("normal");
});
}
else {
$("#ContactRepeat").slideToggle("normal");
}
return false;
});
});
I'm using jQuery 1.2.6. Thank you for your help ahead of time
Upvotes: 1
Views: 352
Reputation: 49242
The major flaw in your code is this line, btw:
$("#ContactRepeat").css("display") == "display"
It'll never be display. Maybe none or block. But it's better to do .is(':visible') or .is(':hidden')
Here's a revised snippet. I'm not seeing any syntax errors being reported when i run this through JSLint
$(function(){
var crepeat = $("#ContactRepeat");
$("#bClose").click(function() { $( crepeat .slideUp("normal"); });
$("#bContact").click(function() {
if (crepeat.is(':visible')){
$crepeat.slideToggle("normal", function(){
$(this).slideToggle("normal");
});
}
else {
crepeat.slideToggle("normal");
}
return false;
});
});
Upvotes: 1