views:

954

answers:

3

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 >>
});
+1  A: 

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
+2  A: 

I think this will work for you

$('td[title]').each(function() {
    $(this).simpletip({
        content : $(this).attr('title')
    });
});
Ken Browning
Ouch! Beaten by 38 seconds! With (almost) the exact same code, too. Mine doesn't have a syntax error, though. ;P
strager
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
+2  A: 
$('td[title]').each(function() {
    $(this).simpletip({
        content : $(this).attr('title')
    });
});
strager