我有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的工具提示文本?
发布于 2011-10-02 12:04:36
看起来你需要使用.each()进行循环。
如下所示:
$('.my_div').each(function(){
$(this).qtip({
content: $(this).attr('data-tooltip'),
style: {
tip: true,
classes: 'ui-tooltip-red'
}
});
});https://stackoverflow.com/questions/7624092
复制相似问题