Twitter's Bootstrap popover not working

心不动则不痛 提交于 2020-01-03 17:12:20

问题


I am using the popover plugin from Bootstrap. (link) but it's not working.

HTML:

<a data-placement='above' class='danger' rel='popover' data-content='test code here' href='#'>Click</a>

Javascript:

<script type='text/javascript' src="../js/jquery.js"></script>
    <script type='text/javascript' src="../js/twipsy.js"></script>
<script type='text/javascript' src="../js/popover.js"></script>

回答1:


The best way is add the following script code:

<script>
    $(function () {
        $("a[rel=popover]")
            .popover({
                offset: 10
            })
            .click(function (e) {
                e.preventDefault()
            })
    })
</script> 

This way, all the a elements with the attribute rel="popover" will get this popover to appear.

No more changes are needed to your code and it works great... at least on my machine, of course ;-)
Try it out!



来源:https://stackoverflow.com/questions/8871073/twitters-bootstrap-popover-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!