我正在使用 slideToggle 技术在我的应用程序中显示和隐藏 100 多个充满信息的 DIV。我有“全部显示”和“全部隐藏”按钮,我希望它们也有 slideToggle 动画(而不仅仅是显示和隐藏所有)。但是在 IE6 上,slideToggle 在应用于每个元素时运行速度非常慢。
有谁知道如何加快速度?另外,我正在切换 msg_head 中的图标,但这并没有减慢它的速度。如果我删除 th slideToggle 并将其替换为仅显示/隐藏(在显示全部/全部隐藏时)它表现良好。但是,如果可能的话,我希望有动画。
<p class="msg_head" onclick="toggleSelection($(this));">Heading</p>
<div class="msg_body">
content
</div>
而我的全部显示和隐藏所有功能......
function toggleSelection(element) {
element.next("msg_body").slideToggle(250);
element.find(":first-child").toggleClass("ui-icon-circle-arrow-s");
element.find(":first-child").toggleClass("ui-icon-circle-arrow-e");
}
function showall() {
$(".msg_head").each(function() {
$(this).next(".msg_body:hidden").slideToggle(250);
$(this).find(":first-child").attr('class','ui-icon ui-icon-circle-arrow-s');
});
}
function hideall() {
$(".msg_head").each(function() {
$(this).next(".msg_body:visible").slideToggle(250);
$(this).find(":first-child").attr('class','ui-icon ui-icon-circle-arrow-e');
});
}
作为记录,单独的 toggleSection() 函数执行完美。并且将 showall 和 hideall 函数中的 slideToggle 替换为 show 和 hide 效果也很好。我真的只是想看看是否有办法让 slideToggle 动画看起来不窒息。