Reformatting a table based photo gallery to a UL based gallery
<p>I have the following code:</p>

<pre><code>var table = $('.photogalleryTable').before('&lt;ul class="photogallery"&gt;&lt;/ul&gt;')
table.find('td a').wrap('&lt;li&gt;').parent().appendTo('ul.photogallery');
table.remove();
</code></pre>

<p>This code finds a table with a list of photos and re-codes it to use a unordered list instead. The script works perfectly except for one issue. If there are 2 galleries on a page, the script will grab all of the images and reformat them into one list. Because the CMS I'm using tags each gallery table with .photogalleryTable, I'm not sure how to keep the script from touching the other galleries. What I would like to have happen is have the script re-format the first instance and then move on to the next instance, keeping the list of photos separate Is that possible?</p>

<p>Here is a sample of the base table code;</p>

<pre><code>&lt;table cellspacing="0" class="photogalleryTable"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="photogalleryItem"&gt;&lt;a title="" href="/images/varsity_basketball/alexdefending.jpg" rel="lightbox[12828]" onclick="myLightbox.start(this);return false;"&gt;&lt;img border="0" alt="" src="/Utilities/ShowThumbnail.aspx?W=80&amp;amp;H=80&amp;amp;Img=%5c%5c192.168.61.7%5canf01%5cyvir%5cfvgrf1%5c67982%5cSbyqref%5c%5cvzntrf%5cinefvgl_onfxrgonyy%5cnyrkqrsraqvat.wct&amp;amp;USM=1"&gt;&lt;/a&gt;&lt;/td&gt;&lt;td class="photogalleryItem"&gt;&lt;a title="" href="/images/varsity_basketball/cheerweb.jpg" rel="lightbox[12828]" onclick="myLightbox.start(this);return false;"&gt;&lt;img border="0" alt="" src="/Utilities/ShowThumbnail.aspx?W=80&amp;amp;H=80&amp;amp;Img=%5c%5c192.168.61.7%5canf01%5cyvir%5cfvgrf1%5c67982%5cSbyqref%5c%5cvzntrf%5cinefvgl_onfxrgonyy%5cpurrejro.wct&amp;amp;USM=1"&gt;&lt;/a&gt;&lt;/td&gt;&lt;td class="photogalleryItem"&gt;&lt;a title="" href="/images/varsity_basketball/hoopcheerteamcombo.jpg" rel="lightbox[12828]" onclick="myLightbox.start(this);return false;"&gt;&lt;img border="0" alt="" src="/Utilities/ShowThumbnail.aspx?W=80&amp;amp;H=80&amp;amp;Img=%5c%5c192.168.61.7%5canf01%5cyvir%5cfvgrf1%5c67982%5cSbyqref%5c%5cvzntrf%5cinefvgl_onfxrgonyy%5cubbcpurregrnzpbzob.wct&amp;amp;USM=1"&gt;&lt;/a&gt;&lt;/td&gt;&lt;td class="photogalleryItem"&gt;&lt;a title="" href="/images/varsity_basketball/piercepipes.jpg" rel="lightbox[12828]" onclick="myLightbox.start(this);return false;"&gt;&lt;img border="0" alt="" src="/Utilities/ShowThumbnail.aspx?W=80&amp;amp;H=80&amp;amp;Img=%5c%5c192.168.61.7%5canf01%5cyvir%5cfvgrf1%5c67982%5cSbyqref%5c%5cvzntrf%5cinefvgl_onfxrgonyy%5ccvreprcvcrf.wct&amp;amp;USM=1"&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="photogalleryItem"&gt;&lt;a title="" href="/images/varsity_basketball/scrappyonfloor.jpg" rel="lightbox[12828]" onclick="myLightbox.start(this);return false;"&gt;&lt;img border="0" alt="" src="/Utilities/ShowThumbnail.aspx?W=80&amp;amp;H=80&amp;amp;Img=%5c%5c192.168.61.7%5canf01%5cyvir%5cfvgrf1%5c67982%5cSbyqref%5c%5cvzntrf%5cinefvgl_onfxrgonyy%5cfpencclbasybbe.wct&amp;amp;USM=1"&gt;&lt;/a&gt;&lt;/td&gt;&lt;td class="photogalleryItem"&gt;&lt;a title="" href="/images/varsity_basketball/teamabove.jpg" rel="lightbox[12828]" onclick="myLightbox.start(this);return false;"&gt;&lt;img border="0" alt="" src="/Utilities/ShowThumbnail.aspx?W=80&amp;amp;H=80&amp;amp;Img=%5c%5c192.168.61.7%5canf01%5cyvir%5cfvgrf1%5c67982%5cSbyqref%5c%5cvzntrf%5cinefvgl_onfxrgonyy%5cgrnznobir.wct&amp;amp;USM=1"&gt;&lt;/a&gt;&lt;/td&gt;&lt;td class="photogalleryItem"&gt;&lt;a title="" href="/images/varsity_basketball/teamarms.jpg" rel="lightbox[12828]" onclick="myLightbox.start(this);return false;"&gt;&lt;img border="0" alt="" src="/Utilities/ShowThumbnail.aspx?W=80&amp;amp;H=80&amp;amp;Img=%5c%5c192.168.61.7%5canf01%5cyvir%5cfvgrf1%5c67982%5cSbyqref%5c%5cvzntrf%5cinefvgl_onfxrgonyy%5cgrnznezf.wct&amp;amp;USM=1"&gt;&lt;/a&gt;&lt;/td&gt;&lt;td class="photogalleryItem"&gt;&lt;a title="" href="/images/varsity_basketball/yeisson.jpg" rel="lightbox[12828]" onclick="myLightbox.start(this);return false;"&gt;&lt;img border="0" alt="" src="/Utilities/ShowThumbnail.aspx?W=80&amp;amp;H=80&amp;amp;Img=%5c%5c192.168.61.7%5canf01%5cyvir%5cfvgrf1%5c67982%5cSbyqref%5c%5cvzntrf%5cinefvgl_onfxrgonyy%5clrvffba.wct&amp;amp;USM=1"&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td colspan="4" class="photogalleryNavigation"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;
</code></pre>
