2012-10-17 102 views
0

我试图让这个工作,但它只是想...工具提示内容qTip2 jQuery

警报提醒正确的内容..任何想法?

function initToolTip() { 
     $('.product').qtip({ 
      content: $(this).find('.product-info').html(), 
      style: 'ui-tooltip-shadow' 
     }); 
     $('.product').on('hover',function(){ 
      //alert($(this).find('.product-info').html()); 
     }); 
    } 
+0

这个解决方案很可能指的是窗口对象,而是在悬停事件中,而是正确引用.product元素 –

回答

1

这里

$(this)不在背景在第一种情况中.product的..

$(this)指的工具提示对象..

使用自定义功能检索..

$('.product').qtip({ 
      content: { 
       text: function(api) { 
       return $(this).find('.product-info').html() ; 
       } 
      }, 
      style: 'ui-tooltip-shadow' 
     }); 
+0

哈哈......这只是晚了......我明天去睡觉并修复它!Thx;) – Mackelito

-1

请,第一RTFM(:P)的第三个例子是你所需要的

,如果你太懒惰,这是在功能您

$('.product').qtip({ 
    content: { 
     text: function(api) { 
      return $('.product-info', this).html(); 
     } 
    } 
});