views:

142

answers:

1

I am trying to use a tooltip jQuery plugin. This is what I have in <head> of index.html:

<head>
    <title>Index</title>
    <link rel="stylesheet" href="style.css" type="text/css" />
    <script src="js/jquery-1.4.2.min.js" type="text/javascript"></script>
    <script src="js/simpletip-1.3.1.min.js" type="text/javascript"></script>
    <script src="js/homepage.js" type="text/javascript"></script>
</head>

And this is in js/homepage.js:

$(document).ready(function() {
    // meaningless functions

    $('.supported_hosts').simpletip({
        fixed: true,
        position: 'right',
        content: 'test content.'
    });
});

But for some reason, the tooltip doesn't show. But it does show if I include the tooltip function on the index page. Is there any way to get this working without having the tooltip function on the index page, but in an external file? Thanks.

+1  A: 

I have never use the simplest plug in but i copy and pasted your header and your js code and everything seemed to work just fine.

I linked to the latest version of jquery and downloaded a fresh copy of simpletip.js and it worked with on the first try.

The only differences are/maybe: - I don't know what your code looks like where you call 'supported_hosts' class in the html. - The name of the simpletip.js file I didn't change it upon download, so I would check your file names and relative location.

Sorry there wasn't something more but what you have worked for me, here is the code I used in full incase this helps you:

HTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;

<head>
    <title>Index</title>
    <link rel="stylesheet" href="style.css" type="text/css" />
    <script src="http://code.jquery.com/jquery-1.4.2.min.js" type="text/javascript"></script>
    <script src="jquery.simpletip-1.3.1.min.js" type="text/javascript"></script>
    <script src="homepage.js" type="text/javascript"></script>
</head>

<body>
     <span class="supported_hosts">Tool Tips here</span>
</body>
</html>

Javascript you gave:

$(document).ready(function() {
    // meaningless functions

    $('.supported_hosts').simpletip({
        fixed: true,
        position: 'right',
        content: 'test content.'
    });
});

I downloaded the simpletip.js here: http://code.google.com/p/jquery-simpletip/downloads/detail?name=jquery.simpletip-1.3.1.min.js&amp;can=2&amp;q=

I would just double check your relative paths and class naming. Your code looks good.

theGoose