我試圖將以下價格和文本放在一起,都放在一個DIV中。jQuery添加div的第一部分,然後添加div的最後一部分seperatley
這是我有:
<table cellspacing="0" cellpadding="0" border="0" class="thePrices">
<tbody><tr>
<td>
<font class="text colors_text">
<b>MSRP: <span class="priceis">$90.00</span></b>
</font><br>
<b><font class="pricecolor colors_productprice">
<font class="text colors_text"><b>Burkett Price:</b></font>
<span class="priceis">$289<sup>.99</sup></span>
</font>
</b><br>
<a href="a link">A link goes here</a>
<table>A TABLE WITH STUFF GOES HERE</table>
</td>
</tr></tbody>
</table>
這是我想獲得:
<table cellspacing="0" cellpadding="0" border="0" class="thePrices">
<tbody><tr>
<td>
**<div class="pricebox">**
<font class="text colors_text">
<b>MSRP: <span class="priceis">$90.00</span></b>
</font><br>
<b><font class="pricecolor colors_productprice">
<font class="text colors_text"><b>Burkett Price:</b></font>
<span class="priceis">$289<sup>.99</sup></span>
</font>
</b><br>
**</div>**
<a href="a link">A link goes here</a>
<table>A TABLE WITH STUFF GOES HERE</table>
</td>
</tr></tbody>
</table>
這並不工作,但你得到的我在做什麼錯誤的想法:
$(document).ready(function() {
$('.thePrices').find('td').find('font:first').before('<div class="pricebox">');
$('.thePrices').find('.colors_productprice').find('b').after('</div>');
});
也許我應該使用SLICE?
你能解釋更多關於你想要輸出是什麼樣子? – Dhiraj 2011-05-10 20:31:32
當然,我只想把第一個字體標籤和B標籤一起包裝在一個div中。在本例中,類爲'pricebox'。 – ToddN 2011-05-10 20:34:16