jQuery Simpletip plugin to use the title attribute

限于喜欢 提交于 2019-12-11 07:55:53

问题


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:


I think this will work for you

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



回答2:


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



回答3:


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.



来源:https://stackoverflow.com/questions/661140/jquery-simpletip-plugin-to-use-the-title-attribute

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!