2

I want to use a font-awesome icon in the tooltip.

<i class="fa fa-info-circle text-success" title="<i class='fa fa-hourglass'></i>: Level-1.
<i class="fa fa-hourglass-half"> : Level-2. 
<i class='fa fa-hourglass'></i> : Level-3."></i> 

The code is incorrect but gives an idea of what I want to do. Any help is appreciated. Thanks in advance.

Aparna
  • 25
  • 2
  • 7

3 Answers3

4

It may be too late. But i found the solution:

use data-html="true" on the seletor you need the tooltip. Example:

$(document).ready(function() {
  $('div').tooltip();
})
.test {
  display: inline-block
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" />
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">


<div class="test" data-placement="bottom" data-html="true" data-toggle="tooltip" title="Check <i class='success fa fa-check'></i> success.">
Hover Me
</div>
<br>what you need:<br>

<div class="fa fa-info-circle text-success" data-placement="bottom" data-html="true" title="<i class='fa fa-star-o'></i> - Level 1<br><i class='fa fa-star-half-o'></i> - Level 2<br><i class='fa fa-star'></i> - Level 3"></div>
3

It might help you

.tooltip {
    position: relative;
    display: inline-block;
    border-bottom: 1px dotted black;
}

.tooltip .tooltiptext {
    visibility: hidden;
    width: 120px;
    background-color: black;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 5px 0;

    /* Position the tooltip */
    position: absolute;
    z-index: 1;
}

.tooltip:hover .tooltiptext {
    visibility: visible;
}
<link href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet"/>
<div class="tooltip">Hover over me
  <span class="tooltiptext"><i class="fa fa-bold"></i><i class='fa fa-hourglass'></i></span>
</div>
Kumar
  • 270
  • 1
  • 4
  • 17
-1

I don't know what you want to do actually but maybe this one you are looking for. I think this will help you. fiddle link

jQuery(document).ready(function($) {
  $('[data-toggle="tooltip"]').tooltip();

})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" type="text/css" />

<div class="container">
 <h3>Hover icon </h3>
 <i class="fa fa-info-circle fa-2x" data-toggle="tooltip" data-placement="bottom" data-html="true" data-original-title="<i class='fa fa-hourglass-half'> Level-1</i> <br> <i class='fa fa-hourglass'> Level-2</i> "> </i>
</div>
Baezid Mostafa
  • 2,680
  • 2
  • 14
  • 26
  • I wanted to give the tooltip on an icon, which I have done. Further, I wanted to use fa icons in the tooltip text, which I wasn't able to do. – Aparna Sep 23 '16 at 11:47