4

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.

3
  • You need to describe your problem in more detail as there's not enough here to say exactly what's wrong. What do you mean by default one? Post a screenshot of your tooltip. Post more code including the javascript files you include on your page, the css you've included and any imbedded javascript. Mar 2, 2012 at 12:37
  • I already have..that's the bit thats relevant, why do u want me to post the whole code?
    – Ali Gajani
    Mar 2, 2012 at 20:09
  • @AliGajani it would help if you posted your markup, just to see what js scripts are included and what is not. Mar 5, 2012 at 11:43

3 Answers 3

7

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

1
  • 8
    Just to add a quick A. You have to add all jQuery functions after the main jQuery library has loaded. they should also be called within the $(document).ready() method. Mar 21, 2012 at 22:45
5

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.

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.