2

我在使用qTip2让带有 html 内容的弹出窗口工作时遇到了一些麻烦。显示的弹出窗口是空白的,我不知道为什么。

这是我的javascript:

$('.tooltip').qtip({
    content: {
        text: function(api){
            $(this).next('.tooltip-content');
        }
    }
});​

我的html是:

<a class="tooltip"></a>
<div class="tooltip-content"><strong>this is some tooltip</strong> content. <em>italic</em></div>​

我已经设置了一个 jsfiddle 来显示我的问题 - http://jsfiddle.net/tajsy/

我计划在一个页面上有很多这些工具提示,所以我想将链接和隐藏的 div 与它的内容配对。

有人可以告诉我哪里出错了吗?

4

2 回答 2

7

Since you are using a function, you need to return the element:

 text: function(api){
     return $(this).next('.tooltip-content');
 }
于 2012-10-18T14:49:59.070 回答
1

qtip2 内联 HTML http://jsfiddle.net/uaR3m/20/

 $('a').each(function() {
     $(this).qtip({
         content: {
             text: function(api){
             return $($(this).attr('href'));
             }

         }
     });
 });
于 2014-05-20T10:16:01.237 回答