【问题标题】:$(...).modal is not a function when using jQuery Modal plugin$(...).modal 在使用 jQuery Modal 插件时不是函数
【发布时间】:2022-12-01 08:36:51
【问题描述】:

我正在使用 this jQuery 模态插件在我的网站上显示一个弹出窗口。

当页面加载时,我想将弹出窗口延迟 5 秒,但不能与“setTimeout”方法一起使用。

这是我的 HTML:

<div id="ex1" class="modal">
<div class="modal-content">
</div>
</div>

记者:

setTimeout(() => {
 $('#ex1').modal({
    fadeDuration: 500,
    showClose: false
 );
}, 5000)

有谁知道如何解决这个问题?

因此,每当我使用“setTimeout”方法时,我都会收到此错误:“Uncaught TypeError: $(...).modal is not a function”,但没有它它也能正常工作。

我怎样才能使这项工作?

【问题讨论】:

    标签: jquery modal-dialog


    【解决方案1】:

    你应该在库之前首先包含 jquery

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-09
      • 2021-08-05
      • 1970-01-01
      • 2021-04-19
      相关资源
      最近更新 更多