【问题标题】:why bootstrap popover is not working with javascript? [duplicate]为什么 bootstrap popover 不能使用 javascript? [复制]
【发布时间】:2020-08-19 12:15:35
【问题描述】:

我正在尝试使用纯 javascript 实现引导弹出窗口。

我知道使用 jquery 很容易实现,但我不能在我的应用程序中使用 jquery。

谁能指导我,我需要修复哪里?

下面是我的代码:

<!DOCTYPE html>
<html lang="en">
<head>
      <title>Bootstrap Example</title>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
      <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</head>
<body>

    <div class="container mt-3">
      <a href="javascript:void(0);" id="myPop" data-toggle="popover" title="Popover Header" data-content="Some content inside the popover" >Toggle popover</a>
    </div>

    <script>
        init();
        function init() {
            document.getElementById( 'myPop' ).style.display = 'block';
        }
    </script>

</body>
</html>

【问题讨论】:

  • Bootstrap 的 Javascript V3 和 V4 需要 jQuery 才能正常运行。
  • 哦。但是有没有办法使用 javascript 来实现这一点?

标签: javascript html bootstrap-4


【解决方案1】:

您需要添加 jQuery 才能使 Bootstrap 正常工作。尝试在引导 javascript 之前添加 jQuery。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-12-05
    • 1970-01-01
    • 2021-05-17
    • 1970-01-01
    • 1970-01-01
    • 2014-10-06
    • 2014-01-27
    • 1970-01-01
    相关资源
    最近更新 更多