![](/img/trans.png)
[英]Why javascript won't work in Twitter's Bootstrap even when calling the function and the js file?
[英]Twitter's Bootstrap Popover: Won't work, even when other JS is working ok
我想使用Twitter的Bootstrap设置弹出窗口。 我已经成功使用了其他JavaScript(下拉菜单和工具提示),但是我无法使用它。
我的页面内有这个html:
<a href="#" id="matriz" rel="popover" data-content="And here's some amazing content. It's very engaging. right?" title="A title">hover for popover</a>
我在文档正文中设置了以下内容:
<script>
$(function() {
$('#matriz').popover({placement: 'bottom', trigger: 'hover', offset: 1});
});
</script>
我已经使用热链接将这样的文件称为:
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script src="https://raw.github.com/twitter/bootstrap/master/js/bootstrap-tooltip.js"></script>
<script src="https://raw.github.com/twitter/bootstrap/master/js/bootstrap-dropdown.js"></script>
<script src="https://github.com/twitter/bootstrap/raw/master/js/bootstrap-popover.js"></script>
<script src="https://github.com/twitter/bootstrap/raw/master/js/bootstrap-twipsy.js"></script>
顺便说一句,使用bootstrap-tooltips.js和bootstrap-twipsy.js是多余的。 工具提示取代了Twipsy。
您缺少的重要部分是主CSS文件bootstrap.css
。
演示: http : //jsfiddle.net/Sn2Zz/
(我不确定在哪里进行热链接,所以我粘贴了bootstrap.css
的内容。)
特别是,您需要.popover-*
样式。
可能是“正在工作”,但您看不到它,因为弹出窗口在DOM中的位置就在</body>
标记之前。
是的-如果您从其他位置加载CSS,则一切正常: http : //jsfiddle.net/dirkk0/5DGef/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.