1

How to add tooltip in jquery? I want to display title, but whatever I try does not work.

JSFiddle: jsfiddle.net/5fsCK/

example: http://jquerytools.org/demos/tooltip/form.html

$(document).ready(function () {
   // What to put here?
});
1
  • you can use qtip2 qtip2.com Commented Feb 5, 2014 at 17:02

5 Answers 5

1

You need to add tooltip jquery file. Add tooptip Js reference(http://cdn.jquerytools.org/1.2.7/full/jquery.tools.min.js) to your header I have added. Please check Demo. You can also use Poshytip

Sign up to request clarification or add additional context in comments.

Comments

0

There's not really a need for jQuery UI or any other external resource. Just add a div with class 'tooltip' and initially set it to display: none. See this JSFiddle: http://jsfiddle.net/NJF8a/

JavaScript

$(document).ready(function () {
    $("input").on("focus", function () {
        $(".tooltip").hide();
        var left = $(this).width();
        var top = $(this).offset().top;
        $(".tooltip").css({
            position: "absolute",
            left: left,
            top: top
        }).html($(this).attr("title")).fadeIn(500);
    }).on("blur", function () {
        if ($(".tooltip").is(":visible")) $(".tooltip").fadeOut(500);
    });
});

1 Comment

That approach kind of defeats the whole reusability aspect of jQuery + UI coding, but hey, whatever the customer wants :)
0

Your example JSFiddle and the JQueryUI sample page work fine when combined:

JSFiddle: http://jsfiddle.net/TrueBlueAussie/5fsCK/1/

The only thing I did was include JQueryUI (and the sample code)

$(document).ready(function () {
    $("#myform :input").tooltip({
        // place tooltip on the right edge
        position: "center right",
        // a little tweaking of the position
        offset: [-2, 30],
        // use the built-in fadeIn/fadeOut effect
        effect: "fade",
        // custom opacity setting
        opacity: 0.7
    });
});

The position is not correct (styling issue), but I am dashing out the door right now :)

Comments

0

Try this working jsfiddle demo

I added some External resources.

$(document).ready(function () {

$('#demo-basic').poshytip({className: 'tip-darkgray',
            bgImageFrameSize: 11,
            offsetX: -25
});
$('#inputtext').poshytip({className: 'tip-darkgray',
            bgImageFrameSize: 11,
            offsetX: -25
});

});

Comments

0

Check this simple code for adding tool tip:

$("element").attr('title', 'tool tip text');

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.