效果:
HTML:
<table border="1" width="100%" class="table_a" style="display:none" id="gallery-tab-table">
<tr><input type="hidden" name="gallery_act" value="gallery_tab"></tr>
<tr>
<th>
<span style="cursor: pointer" οnclick="add_item()">[+]</span>
<label>商品相册</label>
</th>
<td>
<input type="file" name="goods_pics[]" id="goods_pics_0"/>
<div id="goods_pics_div_0">
<img src="" alt="" id="goods_pics_img_0" height="100">
</div>
</td>
</tr>
<script type="text/javascript">
$(function () {
new uploadPreview({
UpBtn: "goods_pics_0",
DivShow: "goods_pics_div_0",
ImgShow: "goods_pics_img_0"
})
})
</script>
</table>
javascript:
<script type="text/javascript">
var num = 1;
function add_item() {
var s = "<tr><th><span style='cursor: pointer' οnclick='$(this).parent().parent().remove()'>[-]</span><label>商品相册</label></th><td><input type='file' name='goods_pics[]' id='goods_pics_"
+ num + "'/><div id='goods_pics_div_" + num + "'><img src='' alt='' id='goods_pics_img_" + num + "' height='100'></div></td></tr>";
$('#gallery-tab-table').append(s);
new uploadPreview({
UpBtn: "goods_pics_" + num,
DivShow: "goods_pics_div_" + num,
ImgShow: "goods_pics_img_" + num
});
num++;
}
</script>