How can you add tooltip to an anchor

You can initialize your tooltips with a title option. There you can pass in a function to get the content you want to show.

$('a').tooltip({
  title: e => $('.fc-title', e).text()
});
a {
  text-align: center;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.bundle.min.js" integrity="sha384-pjaaA8dDz/5BgdFUPX6M/9SUZv4d12SUPF0axWc+VRZkx5xU3daN+lYb49+Ax+Tl" crossorigin="anonymous"></script>

<br /><br />

<a class="fc-day-grid-event fc-h-event fc-event fc-start fc-end fc-draggable" data-toggle="tooltip">
  <div class="fc-content"><span class="fc-time">3:42pm</span> <span class="fc-title">Abc</span></div>
</a>

You can read about the options in the docs.

Leave a Comment