How to put contents into table and then into separate TD's
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.
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/
精彩评论