0
我想为每个5个元素创建一个DIV,我有一个div。你可以在这里看到一个例子:http://www.nobregamedia.com/aa/为每个5个元素创建一个DIV
在底部,我有一个有5个元素的画廊,由橙色的小方块改变。每个橙色方块都有一个到DIV名称的“链接”,例如:DIV1,DIV2,DIV3 ..我需要自动创建它,同时考虑到我从mysql数据库中提取的项目数量。
例如:如果我拉7项,它会创建2个格,和2周的div:DIV1和DIV2 ..等,5的倍数..
我在这里#2看了一些例子,但我不明白他们很多(我是一个JavaScript的新手)。如果你可以帮助我一些代码示例,这将是很好的。
在此先感谢。
下面的代码我现在所拥有的
<div class="idTabs">
<div class="col2">
<a href="#pduno"><img class="pdimg" src="img/pduno.png" width="13" height="11" /></a>
<a href="#pddos"><img class="pdimg" src="img/pddos.png" width="13" height="11" /></a>
<a href="#pdtres"><img class="pdimg" src="img/pddos.png" width="13" height="11" /></a>
</div>
</div>
<div class="row-end"> </div>
<div class="row">
<div class="col101">
<div id="pduno">
<table width="920" border="0" align="left" cellpadding="0" cellspacing="0" style="text-align:left">
<tr>
<td> </td>
</tr>
<tr>
<?PHP
while ($retdetsfinal = mysql_fetch_row($retdest)) {
?>
<td height="110">
<div style="width:160px; height:112px; border:2px solid #c0bdb6">
<img src="imagenes/thumbs/<?php echo $retdetsfinal[0];?>_x.jpg" style="border:6px solid #FFF;" width="148" height="100" />
</div>
<br />
<?php echo ucfirst($retdetsfinal[1]);?> - <?php echo ucfirst($retdetsfinal[2]);?><br />Bs. <?php echo $retdetsfinal[3];?>
</td>
<td> </td>
<?PHP
}
?>
</tr>
</table>
</div>
</div>
</div>
多一点的代码或小提琴会很好。但正如我理解正确,你有例如12张图片,那么你有3个小方块改变可见的div和3个div,其中的图像项是...是正确的? – 2012-04-24 04:15:46
@TobiasKrogh是的,你是对的..我认为正确的词是“包装”的元素。任何想法。??谢谢。! – 2012-04-24 04:20:26
您需要将[slice](http://api.jquery.com/slice/)与[wrapAll](http://api.jquery.com/wrapAll/)结合使用。没有一些代码我不认为你会得到详细的答案 – 2012-04-24 04:36:54