Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap popover with html title tooltip

I want to use a bootstrap popover that gets triggered on click and has a (non-bootstrap) tooltip on hover. Normally you would use html title attribute for this. But on initialisation of a popover, bootstrap writes the content of the title attribute to the data-original-title attribute and replaces title with empty string.

For example this:

<a href="#!" data-toggle="popover" data-title="This is the Popover's Title" data-placement="bottom" data-trigger="click" title="This is a Tooltip">
</a>

becomes this after initialisation:

<a data-original-title="This is a Tooltip" href="#!" data-toggle="popover" data-title="This is the Popover's Title" data-placement="bottom" data-trigger="click" title=""></a>

Since title attribute is now empty, no tooltip is shown.

Is there a way to display a tooltip on a popover anchor with plain html?

like image 434
Jbartmann Avatar asked May 18 '26 03:05

Jbartmann


1 Answers

Hi you can use other data attribute for a title and content of your example, check this:

$('a').each(function() {
  $(this).popover({    
    content : $(this).attr("popover-content"),
    title : $(this).attr("popover-title"),
    placement : "right"
  }),
  $(this).tooltip({    
    title : $(this).attr("tooltip-title"),
    placement : "bottom"
  })
});

<a tooltip-title="This is a Tooltip" href="#!" popover-title="This is the Popover's Title" popover-content="popover content" data-trigger="click">click me</a>

Example on fiddle

like image 100
mcmac Avatar answered May 20 '26 22:05

mcmac



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!