怎样用JS把隐藏表格里的东西调到指定的ID下,每个td生成一个DIV。
<divid="photos"><divstyle="display:none;"class="img-container"><astyle='background:ur...
<div id="photos">
<div style="display: none;" class="img-container ">
<a style='background: url("Photography_files/photo/01.jpg") no-repeat center; height: 260px;' class="box random_portraits" title="1" href="Photography_files/photo/01.jpg">01</a>
<div class="title">1</div>
</div>
</div>
<table id="PicTable" style="display:none; visibility:hidden">
<tbody>
<tr>
<td height="120" valign="middle" align="center"><a href="Photography_files/photo/01.jpg" target="_blank"><img style="WIDTH: 180px; HEIGHT: 120px" id="3392947" title="图片说明" border="1" hspace="0" alt="图片说明" align="center" src="Photography_files/photo/01.jpg" width="180" height="120" relativepic="Photography_files/photo/01.jpg" relativeid="3392948" valign="center"/></a></td>
<td height="120" valign="middle" align="center"><a href="Photography_files/photo/01.jpg" target="_blank"><img style="WIDTH: 180px; HEIGHT: 120px" id="3392947" title="图片说明" border="1" hspace="0" alt="图片说明" align="center" src="Photography_files/photo/01.jpg" width="180" height="120" relativepic="Photography_files/photo/01.jpg" relativeid="3392948" valign="center"/></a></td>
<td height="120" valign="middle" align="center"><a href="Photography_files/photo/01.jpg" target="_blank"><img style="WIDTH: 180px; HEIGHT: 120px" id="3392947" title="图片说明" border="1" hspace="0" alt="图片说明" align="center" src="Photography_files/photo/01.jpg" width="180" height="120" relativepic="Photography_files/photo/01.jpg" relativeid="3392948" valign="center"/></a></td>
<td height="120" valign="middle" align="center"><a href="Photography_files/photo/01.jpg" target="_blank"><img style="WIDTH: 180px; HEIGHT: 120px" id="3392947" title="图片说明" border="1" hspace="0" alt="图片说明" align="center" src="Photography_files/photo/01.jpg" width="180" height="120" relativepic="Photography_files/photo/01.jpg" relativeid="3392948" valign="center"/></a></td>
</tr>
</tbody>
</table>
请求说明:因为排版需要,所以需要把表格隐藏,然后用JS又把表格里的东西调到#photos下。每个td生成一个如下结构的单元:
<div style="display: none;" class="img-container ">
<a style='background: url("photo/01.jpg") no-repeat center; height: 260px;' class="box random_portraits" title="1" href="photo/01.jpg">01</a>
<div class="title">1</div>
</div> 展开
<div style="display: none;" class="img-container ">
<a style='background: url("Photography_files/photo/01.jpg") no-repeat center; height: 260px;' class="box random_portraits" title="1" href="Photography_files/photo/01.jpg">01</a>
<div class="title">1</div>
</div>
</div>
<table id="PicTable" style="display:none; visibility:hidden">
<tbody>
<tr>
<td height="120" valign="middle" align="center"><a href="Photography_files/photo/01.jpg" target="_blank"><img style="WIDTH: 180px; HEIGHT: 120px" id="3392947" title="图片说明" border="1" hspace="0" alt="图片说明" align="center" src="Photography_files/photo/01.jpg" width="180" height="120" relativepic="Photography_files/photo/01.jpg" relativeid="3392948" valign="center"/></a></td>
<td height="120" valign="middle" align="center"><a href="Photography_files/photo/01.jpg" target="_blank"><img style="WIDTH: 180px; HEIGHT: 120px" id="3392947" title="图片说明" border="1" hspace="0" alt="图片说明" align="center" src="Photography_files/photo/01.jpg" width="180" height="120" relativepic="Photography_files/photo/01.jpg" relativeid="3392948" valign="center"/></a></td>
<td height="120" valign="middle" align="center"><a href="Photography_files/photo/01.jpg" target="_blank"><img style="WIDTH: 180px; HEIGHT: 120px" id="3392947" title="图片说明" border="1" hspace="0" alt="图片说明" align="center" src="Photography_files/photo/01.jpg" width="180" height="120" relativepic="Photography_files/photo/01.jpg" relativeid="3392948" valign="center"/></a></td>
<td height="120" valign="middle" align="center"><a href="Photography_files/photo/01.jpg" target="_blank"><img style="WIDTH: 180px; HEIGHT: 120px" id="3392947" title="图片说明" border="1" hspace="0" alt="图片说明" align="center" src="Photography_files/photo/01.jpg" width="180" height="120" relativepic="Photography_files/photo/01.jpg" relativeid="3392948" valign="center"/></a></td>
</tr>
</tbody>
</table>
请求说明:因为排版需要,所以需要把表格隐藏,然后用JS又把表格里的东西调到#photos下。每个td生成一个如下结构的单元:
<div style="display: none;" class="img-container ">
<a style='background: url("photo/01.jpg") no-repeat center; height: 260px;' class="box random_portraits" title="1" href="photo/01.jpg">01</a>
<div class="title">1</div>
</div> 展开
2个回答
展开全部
$(function(){
$('#PicTable tr td').each(function(){
$('#photos').append('<div style="display: block;" class="img-container ">'+$(this).html()+'</div>');
})
})
$('#PicTable tr td').each(function(){
$('#photos').append('<div style="display: block;" class="img-container ">'+$(this).html()+'</div>');
})
})
更多追问追答
追问
谢谢您!我还有个问题呢请教一下,您这个是生成了一个DIV ,也调出了表格里的图片,但是<a style='background: url("Photography_files/photo/01.jpg") no-repeat center; height: 260px;' class="box random_portraits" 这些动作好像没有,能不能麻烦帮忙写全面点。(小弟初学,但是任务紧。谢谢!)
追答
01
你上边这一段是怎么来的?我对比了你的td中间的内容,好像不是这样的?
是重新生成一个a标签,只是引用td中a标签的href?另外你的img标签要不要保留?,有太多问题我不清楚
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询