Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 658
Scott C Wilson Avatar asked Jun 17 '12 23:06

Scott C Wilson


People also ask

How do I show images in popover?

Answer: Use the Popover's content Optionpopover() method to insert the images inside the popovers. You can also set this option using the data-content attribute.

How do I use popovers in bootstrap?

To create a popover, add the data-toggle="popover" attribute to an element. Note: Popovers must be initialized with jQuery: select the specified element and call the popover() method.

How do I show popover in bootstrap 5?

To create a popover, add the data-bs-toggle="popover" attribute to an element. Note: Popovers must be initialized with JavaScript to work.

How do I show popover on hover?

Set the trigger option of the popover to hover instead of click , which is the default one. Or with an initialization option: $("#popover"). popover({ trigger: "hover" });


1 Answers

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/

like image 148
Terry Avatar answered Oct 04 '22 21:10

Terry