gpt4 book ai didi

javascript - Materializecss collapsibles 无法正常工作

转载 作者:可可西里 更新时间:2023-11-01 13:19:36 25 4
gpt4 key购买 nike

我最近开始使用 materializecss 制作网站。一切都很顺利,除了我无法让可折叠物正常工作。它们出现在我的网站上,但根本无法点击。我已经导入了所有的 css 和 js 文件,但这似乎没有帮助。

<html>
<head>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link type="text/css" rel="stylesheet" href="css/materialize.min.css" media="screen,projection"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>

<body>
<ul class="collapsible">
<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>


<script type="text/javascript" src="js/materialize.min.js"></script>
</body>
</html>

<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>

我得到了所有的样式表和脚本,我需要做什么?

最佳答案

问题是你没有初始化 collapsible 这就是它不工作的原因。

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

<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>

<ul class="collapsible">
<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>

关于javascript - Materializecss collapsibles 无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53973266/

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