gpt4 book ai didi

javascript - 单击链接时折叠 Bootstrap Well

转载 作者:行者123 更新时间:2023-11-28 07:10:17 25 4
gpt4 key购买 nike

我使用展开和折叠而不是下拉菜单构建了一个导航菜单。我的问题是单击菜单链接时无法切换 div。我试过在单击链接时使用 js 将其关闭,但我无法再次打开菜单。

这是我的 html:

<header style="padding:0px 0%;">
<nav class="navbar navbar-inverse navbar-static-top" style="margin:0px 0px;">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header hidden-md hidden-lg">
<button type="button" class="navbar-toggle collapsed hidden-sm hidden-xs" data-toggle="collapse" data-target="#myNavmenu" aria-expanded="true" style="color:#fff;display:inline-block;">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>

<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav navbar-right inverse hidden-xs hidden-sm" style="margin:0px 0px; font-size:0.8em;">
<li style="float:left !important"><a href="/" style="text-align: left; padding:8px 0px;"><img src="/products/greg2/images/avatierwatermark.png" style="height:34px; width:auto;"></a></li>
<li><a href="#">Customers</a></li>
<li><a href="#">Solutions</a></li>
<li><a href="#">Products</a></li>
</ul>

</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
</header>


<div class="collapse" id="expandmenu">
<div class="well">
<div class="container">
<button type="button" class="navbar-toggle2 pull-right" data-toggle="collapse" href="#expandmenu" aria-expanded="false" aria-controls="collapseExample" style="float:right; padding:16px 5px 17px 0px; color:#333;"><p class="explore" style="font-size:0.8em; color:#333;">Close </p>
<span class="glyphicon glyphicon-remove" aria-hidden="true" style="font-size:1.1em;"></span>
</button>
<div class="row">
<div class="col-sm-12">

</div>
</div>

<div class="row">


<ul class="expand txt-ctr" style="padding-left:0px;">
<li class="blue"><a href="#passwordstationbenefits" data-toggle="collapse" aria-expanded="false" aria-controls="collapseExample"><div style="background-position:0px 0px;"></div><span>Benefits</span></a></li>
<li class="blue"><a href="#overview" data-toggle="collapse" aria-expanded="false" aria-controls="collapseExample"><div style="background-position:-165px 0px;"></div><span>Overview</span></a></li>
<li class="blue"><a href="#design"><div style="background-position:-330px 0px;"></div><span>Features</span></a></li>
<li class="blue"><a href="#reporting"><div style="background-position:-495px 0px;"></div><span>Reports</span></a></li>
<li class="blue"><a href="#security"><div style="background-position:-660px 0px;"></div><span>Security</span></a></li>
<li class="blue"><a href="#helpdesk"><div style="background-position:-825px 0px;"></div><span>Help Desk</span></a></li>
<li class="blue"><a href="#appsupport"><div style="background-position:-990px 0px;"></div><span>App Support</span></a></li>
<li class="blue"><a href="#architecture"><div style="background-position:-1155px 0px;"></div><span>Architecture</span></a></li>
<li class="blue"><a href="#languages"><div style="background-position:-1315px 0px;"></div><span>Languages</span></a></li>
<li class="blue"><a href="#ticketing"><div style="background-position:-1490px 0px;"></div><span>Ticketing</span></a></li>
<li class="blue"><a href="#textimonials"><div style="background-position:-1665px 0px;"></div><span>Testimonials</span></a></li>
<li class="blue"><a href="/products/identity-management/password-management/password-station/demo/"><div style="background-position:-1825px 0px;"></div><span>Demo</span></a></li>
<li class="blue"><a href="#resources"><div style="background-position:-1998px 0px;"></div><span>Resources</span></a></li>
<li class="blue"><a href="#payingtwice"><div style="background-position:-2165px 0px;"></div><span>True Cost</span></a></li>
</ul>

</div>
</div>
</div>
</div>

这是我试过的 js:

$('.collapse a').click(function(){
$("#expandmenu").toggle();
});

感谢您的帮助!

最佳答案

试试这个,它对我有用:

$('#expandmenu a').click(function(){
$("#expandmenu button").click();
});

关于javascript - 单击链接时折叠 Bootstrap Well,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32699462/

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