When I click togglediv
, commentdiv
must be visible or hidden. The following code is running on Firefox but not Internet Explorer:
$(document).ready(function(){
$("#togglediv").click(function(){
if( $("#commentdiv").is(":visible") ) {
$("#commentdiv").hide("slow");
$("#togglediv").text("show");
} else {
$("#commentdiv").show("slow");
$("#togglediv").text("hide");
}
});
});
There is a function toggle in jquery that does exactly what you want without having to check for visibility:
$("#commentdiv").toggle("slow");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With