gpt4 book ai didi

javascript - 需要帮助才能使此下拉菜单正常工作

转载 作者:行者123 更新时间:2023-11-30 23:58:36 26 4
gpt4 key购买 nike

我按照 https://materializecss.com/dropdown.html 的指示进行操作,仍然无法让这个下拉菜单正常工作。

$(document).ready(function() {
$('.dropdown-trigger').dropdown();
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.0/jquery.min.js"></script>
<!-- Compiled and minified JavaScript -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js">
</script>
<!-- Compiled and minified CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">




<a href="#" class="waves-effect dropdown-trigger" id="dropdown" data-target="dropdown"><i class="material-icons">notifications</i></a>
<!-- Dropdown Structure -->
<ul id="dropdown" class="dropdown-content">
<li><a href="#!">one</a></li>
<li><a href="#!">two</a></li>
<li class="divider" tabindex="-1"></li>
<li><a href="#!">three</a></li>
<li><a href="#!"><i class="material-icons">view_module</i>four</a></li>
<li><a href="#!"><i class="material-icons">cloud</i>five</a></li>
</ul>

</li>

最佳答案

请您检查一下好吗?我发现您的代码中某些 li 项的放置位置错误。此外,您还没有包含jquery。否则这里一切正常。

$(document).ready(function() {
$('.dropdown-trigger').dropdown();
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!-- Compiled and minified JavaScript -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js">
</script>
<!-- Compiled and minified CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">


<a class='dropdown-trigger waves-effect' href='#' data-target='dropdown1'><i class="material-icons">notifications</i></a>
<!-- Dropdown Structure -->
<ul id='dropdown1' class='dropdown-content'>
<li><a href="#!">one</a></li>
<li><a href="#!">two</a></li>
<li class="divider" tabindex="-1"></li>
<li><a href="#!">three</a></li>
<li><a href="#!"><i class="material-icons">view_module</i>four</a></li>
<li><a href="#!"><i class="material-icons">cloud</i>five</a></li>
</ul>

关于javascript - 需要帮助才能使此下拉菜单正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60903120/

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