【发布时间】:2011-11-06 10:25:58
【问题描述】:
我现在有一个位于标签内的链接列表。我希望页面在页面重新加载(页面视图)时“重新组织”每个链接的顺序并显示结果。
例如:
<div id="testgroup">
<a href="1.html" id="1">1</a>
<a href="2.html" id="2">2</a>
<a href="3.html" id="3">3</a>
<a href="4.html" id="4">4</a>
<a href="5.html" id="5">5</a>
</div>
在页面重新加载时,源代码如下所示:
<div id="testgroup">
<a href="5.html" id="5">5</a>
<a href="1.html" id="1">1</a>
<a href="3.html" id="3">3</a>
<a href="4.html" id="4">4</a>
<a href="2.html" id="2">2</a>
</div>
或其他一些随机顺序
是否有一个非常基本的 jQuery DOM 操作脚本来完成这个?如果有帮助,该页面也是基于 PHP 构建的。
【问题讨论】:
-
链接是如何添加到页面的?它们来自数据库吗?你把它们放在一个数组里吗?
-
@Johnie Karr - 暂时和这个例子,它们是静态的并且硬编码到实际的 PHP 页面中
标签: php jquery dom-manipulation