Search code examples
javascripttwitter-bootstrappopover

How do I use popover from Twitter Bootstrap to display an image?


The canonical example for Twitter Bootstrap's popover feature is sort of a tooltip on steroids with a title.

HTML:

<a href="#" id="blob" class="btn large primary" rel="popover" data-content="And here's some amazing content. It's very engaging. right?" data-original-title="A title">hover for popover</a>

JS:

<script>
$("#blob").popover({offset: 10});
</script>

I'd like to use popover to display an image. Is this possible?


Solution

  • Very simple :)

    <a href="#" id="blob" class="btn large primary" rel="popover">hover for popover</a>
    
    var img = '<img src="https://si0.twimg.com/a/1339639284/images/three_circles/twitter-bird-white-on-blue.png" />';
    
    $("#blob").popover({ title: 'Look! A bird!', content: img, html:true });
    

    http://jsfiddle.net/weuWk/