开发者

Issue with qTip2

开发者 https://www.devze.com 2023-04-10 15:41 出处:网络
I have 10 divs. Each one has an attribute data-tooltip=\"text here\". I would something like: $(\'.my_div\').qtip({

I have 10 divs. Each one has an attribute data-tooltip="text here".

I would something like:

$('.my_div').qtip({
      content: $(this).attr('dat开发者_Python百科a-tooltip'),'bottom middle'
      },
      style: {
         tip: true,
         classes: 'ui-tooltip-red'
      }
    });

But it doesn't work. How can I get the tooltip text for each div without writing ten times the code with .qtip function?


It looks like you need to loop with .each() instead.

Something like this:

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

精彩评论

暂无评论...
验证码 换一张
取 消