Div 单击图像时不执行 slideToggle()

Div not performing slideToggle() when clicking on image

我想设置一个作品集,当我点击“3DBanners”的图片时,会打开 ID 为 "FirstBanners" 的 div。

基本上,从这个开始:http://prntscr.com/aufua6 to this: http://prntscr.com/aufups 上下滑动,因此 slideToggle()。

这是我的代码:

#Thumbnails {
 position:absolute;
 top:460px;
 -webkit-filter: drop-shadow(5px 5px 5px rgba(0,0,0,0.70));
    filter:         drop-shadow(5px 5px 5px rgba(0,0,0,0.70));
}
.Thumbs {
 cursor:pointer;
}
.BannerCaptions {
 font-family: Impact, Haettenschweiler, "Franklin Gothic Bold", "Arial Black", sans-serif;
 text-transform:capitalize;
 font-size:26px;
 color:#FFFFFF;
 padding:5px 0px 20px 0px;
}
.StillBanners {
 width:1500px;
}
#DayZSnowy {
 padding-top:15px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<center>
<div id="Thumbnails" style="display:none;">
<a id="FirstBannersThumb"><img src="../Images/Thumbnails/3DBanners.png" alt="3D Banners" class="Thumbs" /></a>
<div id="FirstBanners">
 <img src="../Images/Still Benners/DayZSnowy.png" alt="DayZ Snowy" id="DayZSnowy" class="StillBanners" />
    <p id="DayZSnowyCaption" class="BannerCaptions">DayZ Snowy Banner</p>
    <img src="../Images/Still Benners/InFa.png" alt="InFa Space" id="InFaSpace" class="StillBanners" />
    <p id="InFaSpaceCaption" class="BannerCaptions">InFa Space Banner</p>
    <img src="../Images/Still Benners/L7Zeon.png" alt="L7 Zeon" id="L7Zeon" class="StillBanners" />
    <p id="L7ZeonCaption" class="BannerCaptions">L7 Zeon Banner</p>
    <img src="../Images/Still Benners/Mythh.jpg" alt="Void Mythh" id="Mythh" class="StillBanners" />
    <p id="MythhCaption" class="BannerCaptions">Void Mythh Banner</p>
    <img src="../Images/Still Benners/L7ArtsRiver.png" alt="L7 Arts" id="L7ArtsRiver" class="StillBanners" />
    <p id="L7ArtsRiverCaption" class="BannerCaptions">L7 Arts Banner</p>
    <img src="../Images/Still Benners/Insan3Lik3Var2.jpg" alt="Insan3Lik3" id="Insan3Lik3" class="StillBanners" />
    <p id="Insan3Lik3Caption" class="BannerCaptions">Insan3Lik3 Banner</p>
    <img src="../Images/Still Benners/Soulja.JPG" alt="S3 Soulja" id="Soulja" class="StillBanners" />
    <p id="SouljaCaption" class="BannerCaptions">S3 Soulja Banner</p>
    <img src="../Images/Still Benners/Zorich.jpg" alt="Zorich" id="Zorich" class="StillBanners" />
    <p id="ZorichCaption" class="BannerCaptions">Zorich Banner</p>
    <img src="../Images/Still Benners/Invade.png" alt="L7 Invade" id="Invade" class="StillBanners" />
    <p id="InvadeCaption" class="BannerCaptions">L7 Invade Banner</p>
    <img src="../Images/Still Benners/ExampleFX.jpg" alt="ExampleFX" id="ExampleFX" class="StillBanners" />
    <p id="ExampleFXCaption" class="BannerCaptions">ExampleFX Banner (This is 3D because some buildings in background are 3D Modelled)</p>
    <img src="../Images/Still Benners/Whiz.jpg" alt="SoaR Whiz" id="Whiz" class="StillBanners" />
    <p id="WhizCaption" class="BannerCaptions">SoaR Whiz Banner</p>
    <img src="../Images/Still Benners/Compleqz.jpg" alt="Compleqz" id="Compleqz" class="StillBanners" />
    <p id="CompleqzCaption" class="BannerCaptions">Compleqz Banner</p>
    <img src="../Images/Still Benners/Troopa.JPG" alt="Troopa" id="Troopa" class="StillBanners" />
    <p id="TroopaCaption" class="BannerCaptions">Troopa Banner</p>
    <img src="../Images/Still Benners/Mega3.jpg" alt="Mega" id="Mega" class="StillBanners" />
    <p id="MegaCaption" class="BannerCaptions">Mega Banner</p>
</div>
<a class="Thumbs"><img src="../Images/Thumbnails/2DBanners.png" alt="2D Banners" id="2DBannersThumb" /></a>
<a class="Thumbs"><img src="../Images/Thumbnails/GIFBanners.png" alt="GIF Banners" id="GIFBannersThumb" /></a>
</div>
</center>
<script type="text/javascript">
$(document).ready(function() {
    $("#FirstBannersThumb").click(function() {
        $("#FirstBanners").slideToggle(1000);
    });
});
</script>

尝试更改您的 jQuery 版本。 替换这个

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>

为此

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>

我找到答案了!我只需要删除 document.ready 部分,因为不需要它。