1

How can you make the SimpleTip plugin use each element's title attribute for the tooltip text when you're applying it to a group of elements?

$('td[title]').simpletip({
    content : << this element's title attribute >>
});
nickf
  • 537,072
  • 198
  • 649
  • 721

3 Answers3

5

I think this will work for you

$('td[title]').each(function() {
    $(this).simpletip({
        content : $(this).attr('title')
    });
});
nickf
  • 537,072
  • 198
  • 649
  • 721
Ken Browning
  • 28,693
  • 6
  • 56
  • 68
  • Ouch! Beaten by 38 seconds! With (almost) the exact same code, too. Mine doesn't have a syntax error, though. ;P – strager Mar 19 '09 at 05:41
  • ill vote for yours if you vote for mine haha. anyways, i was missing the ; at first too. i thought "this guy stole my post, typo and all!" ;) – Ken Browning Mar 19 '09 at 05:43
4
$('td[title]').each(function() {
    $(this).simpletip({
        content : $(this).attr('title')
    });
});
strager
  • 88,763
  • 26
  • 134
  • 176
1

I found a hack to do it:

In the Simpletip source code, around line 25:

// change this line:
.html(conf.content)
// to this
.html(conf.content ? conf.content : elem.attr('title'))

and then when you call the simpletip function:

$('td[title]').simpletip({
    content: false
});

Yep, it's a bit hacky, but it works.

nickf
  • 537,072
  • 198
  • 649
  • 721