nickf
nickf

Reputation: 546035

jQuery Simpletip plugin to use the title attribute

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 >>
});

Upvotes: 1

Views: 4116

Answers (3)

Ken Browning
Ken Browning

Reputation: 29091

I think this will work for you

$('td[title]').each(function() {
    $(this).simpletip({
        content : $(this).attr('title')
    });
});

Upvotes: 5

strager
strager

Reputation: 90012

$('td[title]').each(function() {
    $(this).simpletip({
        content : $(this).attr('title')
    });
});

Upvotes: 4

nickf
nickf

Reputation: 546035

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.

Upvotes: 1

Related Questions