I have problem with bootstrap popover, and I have always been confused about that, even after I read some post on stackoverflow. Here is my complete code, and the popover does not work. I have no idea why. Could anybody help me?

<!DOCTYPE html>
<html>

<head>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.3.1/js/bootstrap-    popover.js"></script>
<script src="http://w3resource.com/twitter-bootstrap/twitter-bootstrap-v2/js/bootstrap-tooltip.js"></script>
<script>
$(document).ready(function() {
    $('.moreoption').popover({
        placement : 'top', // top, bottom, left or right
        title : 'This is my Title', 
        html: 'true', 
        content : 'hi'
    });
});
</script>
</head>
<body>
<a href="#" title="" class="moreoption" style="color:black;font-size:13">more</a>
</body>
</html>

One more question that I want to ask is, when we want to use popover, tooltips function in bootstrap, do we need to include the file "bootstrap-tooltips.js" and "bootstrap-popover.js" as our js source? Or we just need to include "bootstrap.min.js" only?

Really appreciate it.

有帮助吗?

解决方案

It looks like you're loading Bootstrap 3 in its entirety, then flopping Bootstrap 2's Popover and Tooltip files on top of that. You're loading parts of Bootstrap twice, and two different versions at that. Remove the Bootstrap 2 files and you should be in business.

To answer your followup question, you can choose to load all of Bootstrap or just the components you want. No need to do both.

You will also need to load the Bootstrap CSS file, by the way: http://www.bootstrapcdn.com

http://jsfiddle.net/isherwood/saAAk/

$(document).ready(function () {
    $('.moreoption').popover({
        placement: 'top', // top, bottom, left or right
        title: 'This is my Title',
        html: 'true',
        content: 'hi'
    });
});
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top