1

This is my current code in order for each of my

 $('#fbNameS1').tipsy({fade: true});
 $('#fbNameS2').tipsy({fade: true});
 ...
 $('#fbNameS207').tipsy({fade: true});
 $('#fbNameS208').tipsy({fade: true});

Now i've seen some jQuery code where they combined DIV ID's together. Before i go and do that to all 209 tipsy's i would like a comfirmation that this would work for the tipsy tooltips?

 $('#fbNameS1','#fbNameS2',....,'#fbNameS207','#fbNameS208').tipsy({fade: true});
StealthRT
  • 10,108
  • 40
  • 183
  • 342
  • 3
    Hiya why not use `class="class_name"` attribute, that way you do not have to write all that just do: `$(".class_name").tipsy({fade: true});` nice and easy :) avoiding pain of 209 element id since Jquery was born :P hope this help! – Tats_innit May 20 '12 at 08:34
  • @Tats_innit: The way tipsy seems to be set up is that for each DIV you want a tool tip on, you have to set it up like i showed in the first code in the OP. Having 209 DIVS with the same name "#fbNamesS" caused the first DIV to have a tooltip while all others did not. Or was it that the first had the tooltip and when you rolled over the others the tooltip would show up still on the first DIV. Ether way, it didnt work with just one :o) – StealthRT May 20 '12 at 08:44

2 Answers2

4

You can try this:

$('div[id^=fbName]').tipsy({fade: true})
Salman
  • 3,761
  • 2
  • 23
  • 34
1

This is a much cleaner way than referencing all those DIVs by ID

First, add a class to each DIV you want to do mass operations on.

<div id='fbNameS1' class='fancyboxMod doTipsyThing' />
<div id='fbNameS2' class='fancyboxMod doTipsyThing' />
<div id='fbNameS3' class='fancyboxMod doTipsyThing' />

Then you can tweak them all with a short selector like this:

$('div.doTipsyThing').tipsy({fade: true});

This is a much more maintainable way to accomplish what you are trying to do.

UPDATE:
I updated my example to show how you would do this if you need to have another class on these elements since you said they required fancyboxMod on them.

JohnFx
  • 34,542
  • 18
  • 104
  • 162
  • **$('a.fancyboxMod').tipsy({fade: true});** and also **$('a[id^=fbNameS]').tipsy({fade: true})** worked! Thanks! – StealthRT May 20 '12 at 09:07