gpt4 book ai didi

javascript - 如果其他打开,jQuery 关闭 ul

转载 作者:行者123 更新时间:2023-11-28 19:20:41 26 4
gpt4 key购买 nike

这里需要一些帮助。我有以下 html/javascript

<div class="quick-links block">
<div class="main-wrap container">
<div class="row">
<div class="col-sm-4 first column">
<div class="inner-content">
<h2>Admissions<a><img src="/sites/all/themes/merge/img/blue-down.png" /></a></h2>
<ul>
<li><a>Apply Now</a></li>
<li><a>Schedule a Visit</a></li>
<li><a>Student Life</a></li>
</ul>
</div><!--end inner-content-->
</div><!--end col-->
<div class="col-sm-4 second column">
<div class="inner-content">
<h2>Academics<a><img src="/sites/all/themes/merge/img/green-down.png" /></a></h2>
<ul>
<li><a>A Liberal Arts Degree</a></li>
<li><a>College of Arts &amp; Sciences</a></li>
<li><a>College of Business</a></li>
<li><a>College of Education</a></li>
<li><a>College of Health Sciences</a></li>
</ul>
</div><!--end inner-content-->
</div><!--end col-->
<div class="col-sm-4 third column">
<div class="inner-content">
<h2>Student Life<a><img src="/sites/all/themes/merge/img/gold-down.png" /></a></h2>
<ul>
<li><a>Campus Photo Tour</a></li>
<li><a>Student Organizations</a></li>
<li><a>Residence Life</a></li>
<li><a>Facilities</a></li>
<li><a>Food &amp; Drink</a></li>
</ul>
</div><!--end inner-content-->
</div><!--end col-->
</div><!--end row-->
</div><!--end container-->
</div><!--end quick-links-->

<!-- ================================================ -->
<!-- === QUICK LINKS JAVASCRIPT === -->
<!-- ================================================ -->

<script>

var quickSection = $('.quick-links');
var quickContent = $('.quick-links .row .inner-content')
var quickList = $('.quick-links .row .inner-content ul');

if ( quickSection.is('*') ) {

quickContent.find("img").click(function() {
$(this).closest(".inner-content").find("ul").slideToggle("slow");
$(this).toggleClass("flipped");
});
}

</script>

如果单击另一个“找到的”img,我需要关闭显示的 ul。基本上只需要在打开另一个 ul 时关闭当前 ul 即可。非常感谢任何帮助。

最佳答案

你也可以这样做

quickContent.find("img").click(function() {
$(this).closest(".main-wrap").find("ul").slideUp("slow"); // close all other
$(this).closest(".column").find("ul").slideDown("slow"); // open current
});

关于javascript - 如果其他打开,jQuery 关闭 ul,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28972415/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com