0

I developed a website using Bootstrap 4 + jquery. I require HTML-styled tooltips, however for some reason the tooltips are populated using the jquery text() and not html(), thus displaying the html as text. I believe my code is correct so no sure what the issue is. Below is an example of a table cell where a tooltip is required. I put in some dummy HTML code in order to check if it works:

<td measureid="3454" data-toggle="tooltip" data-html="true" contenteditable="true" title="<i>3</i><b>6</b>">15</td>

Following the JScode to enable tooltips:

$('[data-toggle="tooltip"]').tooltip({html:true});

Unfortunately the tooltips show the HTML as text. I checked if Bootstrap is actually affecting the tooltip and the tooltip appearance changing when not activating the tooltip using the above JS code.

Any idea what the issue might be?

ceds
  • 2,097
  • 5
  • 32
  • 50

2 Answers2

0

Do you have all scripts path included? I tested your code with Bootstrap v4.5.0 and it is working.

$(function() {
  $('[data-toggle="tooltip"]').tooltip({
    html: true
  });
});
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
<table>
  <tbody>
    <td measureid="3454" data-toggle="tooltip" data-html="true" contenteditable="true" title="<i>3</i><b>6</b>">15</td>
  </tbody>
</table>
yinsweet
  • 2,823
  • 1
  • 9
  • 21
-1

The problem was JQuery UI also having a tooltip library which I referenced. The two libraries clashed and JQuery UI was used. Below answer solved this problem

https://stackoverflow.com/a/19247955/1035217

ceds
  • 2,097
  • 5
  • 32
  • 50