在jquery中有一个函数切换,可以完全按照您的要求进行操作,而无需检查可见性:
$("#commentdiv").toggle("slow");
我会尝试:
$(document).ready(function() { $("#togglediv").click(function() { // note: do this first because the :hidden test fails if you // do it after triggering a slow animation $("#togglediv").text($("#commentdiv").is(":hidden") ? "Hide" : "Sgiw"); $("#commentdiv").toggle('slow'); }); });
编辑:为了回应您的评论,此示例在IE7/FF3中完美适用于我. 注意:在使用慢效果时,我确实必须颠倒语句的顺序.有趣!
Test Hidethanks for answer. but i have tried this code, it was okay. i want to use toggle("slow") effect. this effect is runing firefox, but not i.e. is it a bug?