gpt4 book ai didi

javascript - 嵌套的 ul 在 anchor 击时显示

转载 作者:行者123 更新时间:2023-11-27 23:50:42 25 4
gpt4 key购买 nike

我的网站结构如下:

当我单击“添加信息”时,ul 没有显示,不太确定如何处理它才能显示它?

<ul>
<li>Liebherr LHM 600 Mobile Harbour Crane. <a class="add-info" href="#">Find out more</a>
<ul class="hidden-list">
<li>Liebherr LHM 600 Mobile Harbour Crane. SWL of 208 Ton and capable of lifting 53.7 ton at 58 meters radius. Can be used for bulk container loading/unloading with our Bromma container handler attachment. Maximum hoisting height above quay of 59 metres.</li>
</ul>
</li>
<li>Liebherr LR1300 Crawler Crane. <a class="add-info" href="#">Find out more</a>
<ul class="hidden-list">
<li>Coming December 2014 Liebherr LR1300 Crawler Crane. Can be configured to lift 300.5 ton and can be configured to a maximum radius of 80 metres. Can be fitted with a leader rig attachment and Bruce 16 ton piling hammer for piling.</li>
</ul>
</li>
<li>Sennebogen 6130 Crawler Crane. <a class="add-info" href="#">Find out more</a>
<ul class="hidden-list">
<li>Sennebogen 6130 Crawler Crane. Can be configured to lift 136 ton and has a maximum radius of 42 metres.</li>
</ul>
</li>
<li>Zoomlion RT55 Rough Terrain Crane. <a class="add-info" href="#">Find out more</a>
<ul class="hidden-list">
<li>RT55 Rough Terrain Crane. SWL of 54.88 ton and a maximum working radius radius of 41 metres. A main jib head height of 34 metres but also comes complete with a telescopic fly jib that can increase the head height up to a height of 54 metres and can be offset from 0 to 40 degrees.</li>
</ul>
</li>
<li>Scheuerle 6 axel SPMT modular trailers complete with Z350 power pack units. <a class="add-info" href="#">Find out more</a>
<ul class="hidden-list">
<li>Scheuerle 6 axel SPMT modular trailers complete with Z350 power pack units. With a SWL of 48 ton per axel can be supplied in a vast array of different configurations.</li>
</ul>
</li>
<li>Forklifts <a class="add-info" href="#">Find out more</a>
<ul class="hidden-list">
<li>Various sizes of forklifts available from 2.5 ton up to 32 ton.</li>
</ul>
</li>
</ul>

我想做的是在 jQuery 中单击“添加信息”,显示 ul.hidden-list、SlideDown 或任何效果,只要它显示。

我创建了一个 jsFiddle

我当前的 jQuery 代码:

$('.add-info').click(function() {

$(this).children('ul.hidden-list').slideToggle();

return false;
});

最佳答案

根据您的标记 <ul>元素作为 <a> 的下一个元素放置而不是直系后裔,所以 .next() (或 .siblings )方法应该被使用:

$('.add-info').click(function() {
$(this).next('ul.hidden-list').slideToggle();

return false;
});

演示: http://jsfiddle.net/vog8bsLc/1/

关于javascript - 嵌套的 ul 在 anchor 击时显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27543553/

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