【发布时间】:2018-02-06 00:40:24
【问题描述】:
我有以下代码:
$( document).ready(function() {
$('.modal').modal( {
dismissible: false, // Modal can be dismissed by clicking outside of the modal
opacity: 1, // Opacity of modal background
inDuration: 300, // Transition in duration
outDuration: 200, // Transition out duration
startingTop: '4%', // Starting top style attribute
endingTop: '10%', // Ending top style attribute
}
只要动态打开模态框,上述函数中的选项(例如:不透明度)就不会起作用,例如使用以下代码:
$('#modal1').modal('open');
仅在选择模态触发器时有效:
<a class="waves-effect waves-light btn modal-trigger" href="#modal1">Modal</a>
是什么原因造成的,我该如何解决这个问题?
编辑!
为了澄清,模态是使用两种方法显示的,但是,使用
$('#modal1').modal('open');
模态不遵守不透明度或持续时间等特征。
【问题讨论】:
-
所以你想让 JQuery 代码显示模态?不是当你按下按钮的时候?
-
一个问题你知道你的代码有错误吗?你写的是 .modal 而不是 #modal
-
@Steven 没有错误。在尝试提供此问题的答案之前,请参阅此文档 materializecss.com/modals.html。
-
提示下次在您的问题中向人们明确说明您使用 Materializecss 我教它是一个引导问题
-
@Steven 注意它说在标签中实现。
标签: javascript jquery html material-design materialize