gpt4 book ai didi

javascript - 加载时关闭树切换

转载 作者:行者123 更新时间:2023-12-02 14:41:54 25 4
gpt4 key购买 nike

我不懂 js,但偶尔会使用它,如果问题很琐碎,很抱歉,但我尝试了不同的东西,但它们对我不起作用。

所以我有一棵树,我有这个脚本,它实际上可以工作并在单击时隐藏显示 Twig 。

但是默认情况下树是打开的。如何在树首次加载时强制关闭它?

     <!-- 

- HIDE DISPLAY TREE BRANCH WHEN CLICKED ON HEAD ITEM -->
<script>
$(document).ready(fu

nction () {
$('label.tree-toggler').click(function () {
$(this).parent().children('ul.tree').toggle(300);
});
});
</script>

这是我的源 html

                        <ul class="nav nav-list tree">




<li><div>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;
S: # 2 Men Fashion (<i> <a href="/item/subcategory/subcategory_details/2"> Details </a> - <a href="/item/itemgroup/new/2/http://127.0.0.1:8000/item/category/list/%3Fid=2&name=&keywords=&author=&creation_time=/">Add Itemgroup</a> -
<a href="/item/subcategory/edit/2/http://127.0.0.1:8000/item/category/list/%3Fid=2&name=&keywords=&author=&creation_time=/">Edit</a> -
<a href="/item/subcategory/delete/2/http://127.0.0.1:8000/item/category/list/%3Fid=2&name=&keywords=&author=&creation_time=/">Delete</a></i>)</div>
<ul class="nav nav-list tree">




<li><div><i>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;
I: # 21 ffdsfdsf </i>(<i><a href="/item/itemgroup/itemgroup_details/21">Details </a>-
<a href="/item/itemgroup/edit/21/http://127.0.0.1:8000/item/category/list/%3Fid=2&name=&keywords=&author=&creation_time=/">Edit</a> -
<a href="/item/itemgroup/delete/21/http://127.0.0.1:8000/item/category/list/%3Fid=2&name=&keywords=&author=&creation_time=/">Delete</a></i>)</div>



</li>




<li><div><i>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;
I: # 22 saddascsa </i>(<i><a href="/item/itemgroup/itemgroup_details/22">Details </a>-
<a href="/item/itemgroup/edit/22/http://127.0.0.1:8000/item/category/list/%3Fid=2&name=&keywords=&author=&creation_time=/">Edit</a> -
<a href="/item/itemgroup/delete/22/http://127.0.0.1:8000/item/category/list/%3Fid=2&name=&keywords=&author=&creation_time=/">Delete</a></i>)</div>



</li>




</ul>



</li>

最佳答案

您可以使用 css 添加 display:none到你的ul

喜欢<ul class="nav nav-list tree" style="display:none">

或者在页面加载时调用jquery $(this).parent().children('ul.tree').css('display', 'none') ;

关于javascript - 加载时关闭树切换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36943601/

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