如何将内容放入表中,然后放入单独的 TD 中
这是用 jQuery 完成的:
我已经得到了下一个精确的大量 HTML 块(仅按 ID 逻辑排序):
<!--html massive start-->
<span id="edtL1">myContent</span>
<input type="file" id="fln1" name="file1">
<span id="iCode1">somth</span>
<input type="checkbox" id="del_img1" name="del_img1" value="1">
<label for="del_img1">myDel</label>
<!--/html massive end-->
当页面打开时,我需要将这些块排列在表 td 中已加载。我的页面上有一些由服务器预先生成的块,每个块都有唯一的 ID。我的意思是:
edtL1、fln1、iCode1、del_img1
是唯一的 ID/名称。下一个大规模具有 +1 值(例如 adtL2
等),
因此我需要为每个具有与页面上列出的 id 一样多的大规模生成每个表。
当一切完成后,它必须是这样的:
<table id="codeTbl1"> <!--codeTd1, ..Td2 etc. are generated dynamically after page's loaded-->
<tr><td class="codeTd1">
<span id="edtL1">myContent</span>
</td></tr>
<tr><td class="codeTd2">
<input type="file" id="fln1" name="file1">
</td></tr>
<tr><td class="codeTd3">
<span id="iCode1">somth</span>
</td></tr>
<tr><td class="codeTd4">
<input type="checkbox" id="del_img1" name="del_img1" value="1">
<label for="del_img1">myDel</label>
</td></tr>
</table>
如果有更多相同的 ID +1 满足的质量 - 它们将生成到下一个表,但带有 id="codeTbl2"
。
希望我说清楚了。我需要最简单的解决方案,这样我就可以修改它,因为我是 jQuery 的新手。
This is to be done with jQuery:
I've got the next exact HTML blocks massive (ordered only logically by ID):
<!--html massive start-->
<span id="edtL1">myContent</span>
<input type="file" id="fln1" name="file1">
<span id="iCode1">somth</span>
<input type="checkbox" id="del_img1" name="del_img1" value="1">
<label for="del_img1">myDel</label>
<!--/html massive end-->
I need these blocks to be arranged within the table td's when page is loaded. I've got a few of that blocks massives pregenerated by server with unique ID's each one on my page. I mean the following:
edtL1, fln1, iCode1, del_img1
are unique ID/names. The next massive has +1 value (exmp. adtL2
etc.)
So I need every table to be generated for every massive having those id's as much as they listed on page.
When all is done it must be like this:
<table id="codeTbl1"> <!--codeTd1, ..Td2 etc. are generated dynamically after page's loaded-->
<tr><td class="codeTd1">
<span id="edtL1">myContent</span>
</td></tr>
<tr><td class="codeTd2">
<input type="file" id="fln1" name="file1">
</td></tr>
<tr><td class="codeTd3">
<span id="iCode1">somth</span>
</td></tr>
<tr><td class="codeTd4">
<input type="checkbox" id="del_img1" name="del_img1" value="1">
<label for="del_img1">myDel</label>
</td></tr>
</table>
If there are more same massives with ID +1 met - they are generated to the next table but with id="codeTbl2"
.
Hope I made myself clear. I need the simplest solution so I can modify it as I'm a novice to jQuery.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
究竟什么是“大规模”?
您可以使用模板在 jQuery 中构建表格:
http ://encosia.com/2010/10/05/using-external-templates-with-jquery-templates/
http://encosia.com/2010/11/10/composition-with-jquery-templates-why-and-how/
http://encosia.com/2010 /12/02/jquery-templates-composite-rendering-and-remote-loading/
What exactly is a "massive"?
You can use templates to build a table in jQuery:
http://encosia.com/2010/10/05/using-external-templates-with-jquery-templates/
http://encosia.com/2010/11/10/composition-with-jquery-templates-why-and-how/
http://encosia.com/2010/12/02/jquery-templates-composite-rendering-and-remote-loading/