0

我有 10 个 div。每一个都有一个属性data-tooltip="text here"

我会这样:

$('.my_div').qtip({
      content: $(this).attr('data-tooltip'),'bottom middle'
      },
      style: {
         tip: true,
         classes: 'ui-tooltip-red'
      }
    });

但它不起作用。如何在不编写十倍于.qtip函数的代码的情况下获取每个 div 的工具提示文本?

4

1 回答 1

1

看起来您需要循环使用.each()

像这样的东西:

$('.my_div').each(function(){
    $(this).qtip({
        content: $(this).attr('data-tooltip'),
        style: {
            tip: true,
            classes: 'ui-tooltip-red'
        }
    });
});
于 2011-10-02T04:04:35.937 回答