javascript - why bootstrap popover is not working with javascript?
问题描述
I am trying to implement bootstrap popover using pure javascript.
I know with using jquery it is easy to achieve, but I can't use jquery in my application.
Can anyone guide me, where I need to fix?
Below is my code:
<!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>
解决方案
您需要添加 jQuery 才能使 Bootstrap 正常工作。尝试在引导 javascript 之前添加 jQuery。
推荐阅读
- nlp - Spacy:我应该用一个句子训练模型还是可以通过两个句子的组合?
- asynchronous - Flutter:我无法从 Firestore 集合中获取文档……为什么?
- cypress - 断言请求没有发生
- python - 如何使用本地机器调度程序每分钟运行一次 python 脚本?
- laravel - Laravel 5.5 - 成功登录后如何向 Auth::user() 添加自定义值
- tensorflow - Tensorflow-GPU:ImportError:DLL load failed:找不到指定的模块
- javascript - 执行 ajax POST 时,options.data.indexOf 不是函数
- python-3.x - 需求的正则表达式模式
- ios - 当我选择标签栏按钮时无法更改我的色调颜色
- xcode - Xcode 11 / iOS 13 没有控制台输出