简体   繁体   English

带有html内容的qTip2

[英]qTip2 with html content

I'm having some trouble getting popups with html content to work using qTip2 . 我在使用qTip2获取带有html内容的弹出窗口时遇到了一些麻烦。 The popup that is displayed is blank and I'm not sure why. 显示的弹出窗口是空白的,我不知道为什么。

Here is my javascript: 这是我的javascript:

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

And my html is: 我的HTML是:

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

I have set up a jsfiddle showing my problem - http://jsfiddle.net/tajsy/ 我已经设置了一个jsfiddle显示我的问题 - http://jsfiddle.net/tajsy/

I plan to have lots of these tooltips on one page so I would like to pair up the link and the hidden div with the content for it. 我计划在一个页面上有很多这些工具提示,所以我想将链接和隐藏的div与内容配对。

Can someone tell me where I'm going wrong? 谁能告诉我哪里出错了?

Since you are using a function, you need to return the element: 由于您使用的是函数,因此需要返回元素:

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

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

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

         }
     });
 });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM