jQueryUI工具提示,标题属性中包含html内容

时间:2013-12-16 19:08:45

标签: jquery jquery-ui jquery-ui-tooltip

嗨,我有这个问题Jquery UI tooltip does not support html content,我已尝试过所有解决方案,但没有人对我有所帮助。 事实上,我尝试使用此代码并且无法正常工作

<script>
    $(document).ready(function () {
        $('li.thumbnail a').tooltip({
            content: function () {
                return 'hola';
            }
        });
    })
</script>

我该怎么办?

1 个答案:

答案 0 :(得分:0)

将html放在工具提示中没问题。只需要小心html的特殊字符(用html实体替换它们或替换双重“和单引号”)如果你想让它变得动态,请使用.attr()而不是jQuery UI方法。即:

使用:

$('selector').attr('title', 'content here' );

而不是:

$('selector').tooltip({content: 'content here'});

您可以在this fiddle.

中找到工作示例
相关问题