Question

I'm trying to use this tooltip plugin: http://bassistance.de/jquery-plugins/jquery-plugin-tooltip/. I can't seem to get it to work.

<head>
    <script type="text/javascript" src="/static/JQuery.js"></script>
    <script type="text/javascript" src="/static/jquery-ui-1.8.1.custom.min.js"></script>
    <script type="text/javascript" src="/static/jquery.json-2.2.min.js"></script>
    <script type="text/javascript" src="/static/jquery.form.js"></script>
    <script type="text/javascript" src="/static/js-lib/jquery.bgiframe.js"></script>
    <script type="text/javascript" src="/static/js-lib/jquery.delegate.js"></script>
    <script type="text/javascript" src="/static/js-lib/jquery.dimensions.js"></script>
    <script type="text/javascript" src="/static/jquery.tooltip.js"></script>
    <script type="text/javascript" src="/static/sprintf.js"></script>
    <script type="text/javascript" src="/static/clientside.js"></script>
</head>

I try it out in a simple example:

clientside.js:

$(document).ready(function () {

    $("#set1 *").tooltip();
});

The target html:

   <div id="set1">
                <p id="welcome">Welcome. What is your email?</p>
                <form id="form-username-form" action="api/user_of_email" method="get">
                    <p>
                    <label for="form-username">Email:</label>
                    <input type="text" name="email" id="form-username" />
                    <input type="submit" value="Submit" id="form-submit" />
                    </p>
                </form>
                <p id="msg-user-accepted"></p>
            </div>

Unfortunately, nothing happens. What am I doing wrong?

Was it helpful?

Solution

You need a title attribute on your elements to get the tooltip, like this:

<input type="text" name="email" id="form-username" title="My Tooltip" />

You can see a demo here

Also make sure you're including the CSS file, or have CSS of your own to style the tooltip, the default stylesheet the tooltip plugin includes is:

#tooltip {
    position: absolute;
    z-index: 3000;
    border: 1px solid #111;
    background-color: #eee;
    padding: 5px;
    opacity: 0.85;
}
#tooltip h3, #tooltip div { margin: 0; }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top