好的,我碰到了一堵磚牆。我有一個項目,我需要將表中列出的項目(照片)轉換爲UL進一步的jQuery操作(理想情況下使用jQuery Cycle - http://www.malsup.com/jquery/cycle/)。我找到了這個堆棧溢出帖子(How to transform HTML table to list with JQuery?),但是這個代碼似乎有點用處和特定於OP的使用。我也很好奇這是否需要在頁面加載的某個點執行(DOM準備就緒,Post DOM準備就緒等)。使用jQuery處理和轉換表格項目
不幸的是,我沒有太多格式化輸出的選項,因爲它是由第三方模塊生成的。目前,輸出格式,像這樣(簡體空間和清晰度編號和網址):
<!-- First Item, I can set this to format however I like -->
<a href="16.jpg" rel="lightbox2" title=""><img src="16.jpg" class="FirstPhoto" alt="" width="320" height="240" /></a>
<!-- Subsequent Items are put into a table, as the developer has explained - rendered as a Datalist -->
<table id="CMS-ASSIGNED-UNIQUEID" cellspacing="0" cellpadding="0" border="0" style="width:100%;border-collapse:collapse;">
<tr>
<td align="center">
<a href="17.jpg" rel="lightbox2" title=""><img src="17.jpg" class="ItemPhoto" width="125" height="94" alt=""></a>
</td>
<td align="center">
<a href="18.jpg" rel="lightbox2" title=""><img src="18.jpg" class="ItemPhoto" width="125" height="94" alt=""></a>
</td>
</tr>
<!-- Continue for n Rows -->
</tr>
</table>
理想情況下,我想獲得它這樣的出口(注意,第一個項目也是在那裏,我可以解決此,如果它超出了什麼是可能的)範圍:
<div class="slideshow">
<img src="16.jpg" width="125" height="94" />
<img src="17.jpg" width="125" height="94" />
<img src="18.jpg" width="125" height="94" />
</div>
假設其他'a [rel = lightbox2]> img'可以在同一頁面上存在是合理的,在這種情況下,'$('#CMS-ASSIGNED-UNIQUEID a [rel = lightbox2]> img')'將會更適合避免移動不需要的圖像。 – 2009-10-06 17:07:32
這是一個很好的觀點。使用該選擇器的缺點是不包含第一個img標籤(表格外的標籤)。 OP提到能夠解決這個問題。 – dcharles 2009-10-06 17:24:41
事實上,我相信我可以解決這個問題,但是如果它可以包括,那就更好了。在閱讀了迄今爲止的幾個答案之後,我應該能夠完成這項工作。我很感謝大家對此的幫助! – SilentBobSC 2009-10-06 17:52:03