Jquery 如何将html标记包装在图像标记周围?
我想转换下面的html图像标签Jquery 如何将html标记包装在图像标记周围?,jquery,html,css,Jquery,Html,Css,我想转换下面的html图像标签 <img src="img-1.jpg" width="290" height="420" class="frameImage" /> 使用jquery创建以下代码 <table class="frame" border="0" cellpadding="0" cellspacing="0"> <tr> <td class="border-top" colspan="3"></td>
<img src="img-1.jpg" width="290" height="420" class="frameImage" />
使用jquery创建以下代码
<table class="frame" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="border-top" colspan="3"></td>
</tr>
<tr>
<td class="border-left"></td>
<td><div class="image-frame"><img src="img-1.jpg" width="290" height="420" class="frameImage" />
<div class="top-left"></div>
<div class="top-right"></div>
<div class="bottom-right"></div>
<div class="bottom-left"></div>
</div></td>
<td class="border-right"></td>
</tr>
<tr>
<td class="border-bottom" colspan="3"></td>
</tr>
</table>
$('img[src=img-1.jpg]')。在('
)。删除();
$('img[src=img-1.jpg]')。在('
)。删除();
您应该能够执行以下操作:
$('.image-frame').html('<img src="img-1.jpg" width="290" height="420" class="frameImage" /%gt;')
$('.image frame').html('
但这需要您先打印表格,然后将图像插入表格中您应该能够执行以下操作:
$('.image-frame').html('<img src="img-1.jpg" width="290" height="420" class="frameImage" /%gt;')
$('.image frame').html('
但这需要您先打印表格,然后将图像插入表格中。这不完全是答案,但您可能会感兴趣。这不完全是答案,但您可能会感兴趣。您为什么要这样做?看起来他想在表格周围加上一个特殊的边框。这有这么多HTML,应该是首先最好使用它,或者在服务器端生成它。你为什么要这样做?看起来他想在它周围加一个特殊的边框这是如此多的HTML,首先最好使用它,或者在服务器端生成它。如果你使用.frameImage作为选择器会更好。frameImage使用这个选项选择所有元素class.img[src=img-1.jpg]准确地选择带有此图像的图像标记。我认为代码只是一个示例。它应该更准确。如果使用.frameImage作为选择器会更好。.frameImage选择带有此类的所有元素。img[src=img-1.jpg]选择与此图像完全一致的图像标记。我认为代码只是一个示例。它应该更精确。