为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

一只斗牛犬 2023-10-16 10:44:38
我按照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>
查看完整描述

1 回答

?
素胚勾勒不出你

TA贡献1827条经验 获得超9个赞

请您检查一下好吗?我发现您的代码中某些项目的放置位置错误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>


查看完整回答
反对 回复 2023-10-16
  • 1 回答
  • 0 关注
  • 104 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信