4

I'm looking for a jQuery tooltip plugin that doesn't use the <title> attribute. I've tried a few variations so far including; Tooltipster, PowerTip, jTip and TipTip! They all work but don't all work properly in IE8 (this is a must). They also all use the <title> attribute.

I need to be able to use other <html> tags such as <p> etc within the containing block hence the need to not use <title>. A plugin that uses <div> or similar would be perfect as I can then customise to how I want and use the relevant <html> tags.

I've searched and searched and searched but can't find anything, so if anybody knows of one I would greatly appreciate it!

2
  • You can simply change how the plugins pull data - instead of pulling text from the title attribute, you can make it to search in the target element for a specific div, or even pull data from customized HTML5 data- attributes. You'll have to dig into the source code to make the changes. Commented Jun 11, 2013 at 7:54
  • jQuery UI's tooltip widget can display arbitrary content and supports Internet Explorer 6, 7 and 8. Commented Jun 11, 2013 at 7:55

7 Answers 7

5

The issue is that though you can specify {content:''} for your tooltip it requires a title tag or that you specify a alternate for it to use, even if it will not use the attributes value.

However the value that you pass in for {items:'selector'} is a selector. By default it is {items:'[title]'}. Instead of setting the selector to an attribute it can set it to the name of the tag it is being applied to. In your case, and frankly in most cases anyone would be manually setting a tooltip, you can use {items:'*'} which is a wild card selector and will work for any element.

Markup:

<p class="example">
  Joke Part One.
</p>

Script:

$('.example').tooltip({
  content: 'This will be your working tooltip',
  items:'*'
});

Example: http://jsbin.com/depax/5/edit?html,js,output

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

Comments

4

You can use the jQuery Tooltip without title using custom-content like:

$(function () {
    var content = 'We ask for your age only for statistical purposes.';
    $(document).tooltip({
        items: "input",
        content: function () {
            var element = $(this);
            if (element.is("input")) {
                return "<p class='arrow'>" + content + "</p>";
            }
        }
    });
});

FIDDLE DEMO

3 Comments

Thanks I'll take a look at this. Is this backwards compatible? My concern is that I'm using jQuery version 1.5.1 (not my choice). I can update the version of jQuery but I need to make sure any components will support IE8.
@Kiz you can use the jQuery Migrate Plugin for that..
Thanks, ended up editing tooltipster but by changing the content as per your answer!
1

You can use twitter bootstrap for the tooltips. There are many expandable plugins are available online.

http://twitter.github.com/bootstrap/javascript.html

Comments

1

You can pull the content from a standard or custom (data-) attribute in the target element like this:

$(document).tooltip({ items: "a[data-title]" },
{content: function(){
return $(this).attr("data-title");
}
});

Here the 'content' option is defined as a function that returns the value of the data-title attribute. There are many more cases for using a function to return the content of the tooltip, e.g. it could return the result of an AJAX call or other dynamic content.

If you wanted to include formatted HTML in your tooltip, the content:function could retrieve the inner HTML of a hidden div on the page.

Comments

0

You can try twitter bootstrap popover, and you can customize the css.

have a look into it.

http://twitter.github.io/bootstrap/javascript.html#popovers

Comments

0

This is a bit hacky but when items doesn't work for you (let's say you are doing for multiple selectors at once) you can also set title on the fly:

$(el).attr('title', '')
     .tooltip({
          content: //...
          position: //...
      });

Comments

-1

Title is an attribute of HTML tags. You can customize the library according to your need.

You can define a different attribute instead of title and then use as tooltip.

e.g.

<div tooltip_text="hello world!"> ... </div>

1 Comment

that's invalid HTML. You need to use data- attributes, eg data-tooltip-text

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.