可能重复:
我怎样才能让这个 jQuery 比我拥有的更快?
目前,我将此脚本用于一种“选项卡”系统。单击一个选项卡时,它会隐藏所有其他选项卡。他们都是div的。但是现在,我认为在选定的 div 加载之前它的衰减速度还不够快。它最终在被选中并正在显示的 div 下方移动。
我不想要切换,因为如您所见,我有 5 个选项卡,我想在单击它们时打开它们各自的“_s”div。淡出,淡入。
有什么方法可以让淡出在淡入之前发生,或者添加延迟?我不知道如何在这个脚本中添加延迟,或者在新的 div 淡入之前检查以确保 div 完全淡化。
几天前我发布了同样的问题,但还没有找到正确的答案。
这是我当前用于打乱标签的工作脚本。堆栈的格式很奇怪。编辑帖子并在需要时阅读。
在发生任何事情之前,我制作了一个单独的脚本来隐藏加载时除第一个选项卡之外的所有 div。这可以集成到您的解决方案中,这样我就没有一百个脚本了吗?这是来源:
<script>
$(document).ready(function () {
$('#campus_infotab_two_s,#campus_infotab_three_s,#campus_infotab_four_s,#campus_infotab_five_s').hide();
});
</script>
Now here's the script that controls the "tabs."
<script>
$("#teach_one").click(function() {
$("#teach_one_s").fadeIn("slow");
$("#teach_two_s").fadeOut("fast");
$("#teach_three_s").fadeOut("fast");
$("#teach_four_s").fadeOut("fast");
$("#teach_five_s").fadeOut("fast");
});
$("#teach_two").click(function () {
$("#teach_two_s").fadeIn("slow");
$("#teach_one_s").fadeOut("fast");
$("#teach_three_s").fadeOut("fast");
$("#teach_four_s").fadeOut("fast");
$("#teach_five_s").fadeOut("fast");
});
$("#teach_three").click(function () {
$("#teach_three_s").fadeIn("slow");
$("#teach_one_s").fadeOut("fast");
$("#teach_two_s").fadeOut("fast");
$("#teach_four_s").fadeOut("fast");
$("#teach_five_s").fadeOut("fast");
});
$("#teach_four").click(function () {
$("#teach_four_s").fadeIn("slow");
$("#teach_one_s").fadeOut("fast");
$("#teach_two_s").fadeOut("fast");
$("#teach_three_s").fadeOut("fast");
$("#teach_five_s").fadeOut("fast");
});
$("#teach_five").click(function () {
$("#teach_five_s").fadeIn("slow");
$("#teach_one_s").fadeOut("fast");
$("#teach_two_s").fadeOut("fast");
$("#teach_three_s").fadeOut("fast");
$("#teach_four_s").fadeOut("fast");
});
</script>
现在,这是它制作的漂亮的 HTML:
<ul class="noselect teach_home_navigator_tabs">
东西 东西 东西 东西 东西 东西
这是我的一些建议,但没有一个有效。Hunter 提供的那个似乎应该可以工作,但它说某处存在语法错误,我对 jquery 的诊断不是很好。谢谢!