gpt4 book ai didi

javascript - 从 Material 可折叠中获取事件索引

转载 作者:行者123 更新时间:2023-12-03 03:04:41 26 4
gpt4 key购买 nike

我想获取materialcss折叠中事件的索引。

我尝试过以下代码

function getActive() { return($('.active').data("index")) } $(document).ready(function(){ $('.collapsible').collapsible(); });
<!-- Compiled and minified CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/css/materialize.min.css">

<!-- Compiled and minified JavaScript -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/js/materialize.min.js"></script>

<ul class="collapsible" data-collapsible="accordion">
<li>
<div class="collapsible-header"><i class="material-icons">filter_drama</i>First</div>
<div class="collapsible-body"><span>Lorem ipsum dolor sit amet.</span></div>
</li>
<li>
<div class="collapsible-header"><i class="material-icons">place</i>Second</div>
<div class="collapsible-body"><span>Lorem ipsum dolor sit amet.</span></div>
</li>
<li>
<div class="collapsible-header"><i class="material-icons">whatshot</i>Third</div>
<div class="collapsible-body"><span>Lorem ipsum dolor sit amet.</span></div>
</li>
</ul>

最佳答案

您想要使用.index()功能:

function getActive() { return $('.active').index(); }

关于javascript - 从 Material 可折叠中获取事件索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47218535/

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