Hi everyone, I have very limited knowledge when it comes to javascript and need some help.

See I have a tool tip jquery function that works with ids. Instead of me writing 24 functions i wanted to include a for loop but I don't know how. How would i implement the for loop into the function?
Hopefully this can help on what iam trying to do.
thanks!

<script type="text/javascript">
for (i = 0; i <= 24; i++)
{
document.write(
 jQuery.noConflict();
  jQuery(function() {
  jQuery('#box "+ i" a').tooltip({
    track: true,
    delay: 0,
    showURL: false,
    showBody: " - ",
    fade: 250
});
});
)
}
  </script>

html would be 24 tables like this

table width="80" border="0" cellpadding="2" cellspacing="2" id="box1">
      <tr> <td valign="top"><a href="images/fish.jpg" target="_blank" rel="lightbox" title="fish"><img src="images/fishlb.jpg" alt="fish" width="60 height="45" border="0"  /></a></td>
      </tr>
      <tr>
        <td  align="center"><span style="font-size:9px;">fish </span> </td>
      </tr>
    </table>

document.write accepts a string as a parameter, not a block of javascript code.
The way jQuery works, you should not need to write a loop. You can just find all your elements and call the tooltip function on all of them.
In the following example, the code is looking for all anchors that have class="tt"

<a href="img1.jpg" class="tt">Image 1</a>
<a href="img2.jpg" class="tt">Image 2</a>
<a href="img2.jpg" class="tt">Image 3</a>

<script type="text/javascript">
jQuery(function() {
    jQuery("a.tt").tooltip({ track: true, delay: 0 });
});
</script>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.