Ali Gajani
Ali Gajani

Reputation: 15089

Bootstrap tooltip isn't working

My JavaScript:

<script>
    $(function(){
        $('a[rel=tooltip]').tooltip();
    });
​</script>

And my HTML:

<br><br><br>This is an example of a sentence with a
<a href="#" rel="tooltip" title="This is the tooltip!">tooltip</a>!

This doesn't show the Bootstrap 2.0 tooltip but shows some default one.

Upvotes: 4

Views: 15917

Answers (3)

Rose Perrone
Rose Perrone

Reputation: 63616

Let's say you've declared your tooltips declared as follows:

<a href="#" rel="tooltip" class="tip" title="Rating:' + rating + '">'+ name +'</a>

In the same file, make sure you include:

<script type="text/javascript">
     $('.tip').tooltip();
</script>

Note that you should either refer to this code after the HTML it references, or wrap it in

<script type="text/javascript">
    $(document).ready(function() {
        $('.tip').tooltip();
    });
</script>

Also note that the jQuery selector refers to a class of tooltips and not just the id of one tooltip.

Upvotes: 5

Case Sensitive
Case Sensitive

Reputation: 11

Make sure you have all the css styles for the .tooltip class loaded.

Without these the tooltip may be displayed outside the visible part of your browser window.

Upvotes: 0

Karthik
Karthik

Reputation: 228

Try adding the code in footer. it worked for me! for some reason it doesn't work in header!

Upvotes: 7

Related Questions