gpt4 book ai didi

javascript - 如何养育 child ul?

转载 作者:行者123 更新时间:2023-11-28 15:57:47 25 4
gpt4 key购买 nike

我需要获取单击跨度的父 li,然后显示该 li 的子 ul

 <ul id="menu">
<div>
<li class="reveal">
<a href="##">!!!!!!!!!!!!</a>
<span class="arrow_open">↓</span><br/> <!-- clicking this one -->
<ul> <!-- display this one -->
<li>a</li>
<li>b</li>
<li>c</li>
</ul>
</li>
</div>
</ul>

还有我的代码。

$(function () {
$(this).parent("li").child("ul").slideToggle();
});

最佳答案

您必须在跨度上设置一个点击处理程序,如下所示

$(function () {
$('#menu .reveal span').on('click', function(){
$(this).parent().find("ul").slideToggle();
});
});

关于javascript - 如何养育 child ul?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18044982/

25 4 0
文章推荐: javascript - Chrome 不会触发内容可编辑 iframe 中文档的焦点和模糊事件
文章推荐: html - CSS背景图片网址仅接受完整路径
文章推荐: html - 如何让两个
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com