我试图使用toggle,slideUp和slideDown来显示和隐藏一系列div.我能够将div转换为slideDown,但我无法将其转换为slideUp.我以前没有使用这个脚本,所以我真的很困惑为什么这不起作用.我已经包含了我的脚本和我试图显示和隐藏的div.
快速注意:当我在"隐藏的车辆"div中放置一个普通的旧p标签时,它工作正常.它显示和隐藏像它应该的那样.但是,当我把我的桌子放回那个div时,它没有用.
<script type="text/javascript">
$(document).ready(function() {
$(".ShowVehicles").toggle(function() {
$(".HiddenVehicles").slideDown(2000);
$(this).text("Hide All");
}, function () {
$(".HiddenVehicles").slideUp(2000);
$(this).text("Show All");
});
});
Run Code Online (Sandbox Code Playgroud)
<div class="HiddenVehicles" style="display:none; width:730px;">
(there will be a giant table in here)
</div>
Run Code Online (Sandbox Code Playgroud)