Reformatting a table based photo gallery to a UL based gallery

Posted by mmsa on Stack Overflow See other posts from Stack Overflow or by mmsa
Published on 2010-04-06T23:35:30Z Indexed on 2010/04/06 23:43 UTC
Read the original article Hit count: 582

Filed under:

I have the following code:

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

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?

© Stack Overflow or respective owner

Related posts about jQuery