Fred Collins
Fred Collins

Reputation: 5010

Issue with qTip2

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

I would something like:

$('.my_div').qtip({
      content: $(this).attr('data-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?

Upvotes: 0

Views: 198

Answers (1)

thirtydot
thirtydot

Reputation: 228152

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'
        }
    });
});

Upvotes: 1

Related Questions