gpt4 book ai didi

javascript - MaterializeCSS 组件缺少一些关键内容

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

我一直在努力让 MaterializeCSS 元素在我的项目中正常工作。 JS 函数都不起作用,我不知道为什么。

这是我的JSFiddle这是行不通的。

据我所知,它是 this one 的精确复制品。确实如此。那么还缺少什么?

$( document ).ready(function() {
$('.modal').modal();
$('#modal1').on('click', function() {
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.1/js/materialize.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.1/css/materialize.min.css" rel="stylesheet"/>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<a class="waves-effect waves-light btn view" data-target="modal1">View Scores</a>
<!-- Modal Structure -->
<div id="modal1" class="modal">
<div class="modal-content">
<h4>Modal Header</h4>
<p>A bunch of text</p>
</div>
<div class="modal-footer">
<a href="#!" class=" modal-action modal-close waves-effect waves-green btn-flat">Agree</a>
</div>
</div>

谢谢

最佳答案

问题是:materialize需要jquery,因此您需要在materialize.js之前先导入jquery

enter image description here

$( document ).ready(function() {
$('.modal').modal();
$('#modal1').on('click', function() {
});
});
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.1/js/materialize.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.1/css/materialize.min.css" rel="stylesheet"/>
<a class="waves-effect waves-light btn view" data-target="modal1">View Scores</a>
<!-- Modal Structure -->
<div id="modal1" class="modal">
<div class="modal-content">
<h4>Modal Header</h4>
<p>A bunch of text</p>
</div>
<div class="modal-footer">
<a href="#!" class=" modal-action modal-close waves-effect waves-green btn-flat">Agree</a>
</div>
</div>

关于javascript - MaterializeCSS 组件缺少一些关键内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44467930/

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