Image in tooltip using bootstrap?

dkx22 picture dkx22 · Apr 6, 2015 · Viewed 51k times · Source
<button title="Tooltip on right" data-placement="right" data-toggle="tooltip" class="btn btn-default mrs" type="button">Tooltip on right</button>


<script>
  $(function () {
    $('[data-toggle=tooltip]').tooltip();
  });
</script>

This works fine but I'd like to include an image and some text inside the tooltip. I tried to use data-content="some stuff" but it shows nothing.

Answer

joshvito picture joshvito · Apr 6, 2015

You have to pass in the html option to when you initialize .tooltip. e.g.

<div class="cart"> 
    <a data-toggle="tooltip" title="<img src='http://getbootstrap.com/apple-touch-icon.png' />">
        <i class="icon-shopping-cart"></i>
    </a>

$('a[data-toggle="tooltip"]').tooltip({
    animated: 'fade',
    placement: 'bottom',
    html: true
});

See the example fiddle