开发者

Sort Div id by using Php (or by java)

Is there a fairly easy way to sort div id's with php? I tried a jquery script to sort it be it gave a big delay on the page load.

Example html part (unsorted)

<div id="开发者_如何转开发1">Content1</div>
<div id="3">Content3</div>
<div id="2">Content2</div>

Example html part (End result, Sorted with php or java)

<div id="1">Content1</div>
<div id="2">Content2</div>
<div id="3">Content3</div>

Thank you, Bjorn


You can, using the DOM extension. See DOMNode::insertBefore and DOMNode::removeChild.

However, you should ask yourself why they're unsorted in the first place.

Do they come from a database? In that case you can sort the query. They come from some place else? Try to to reorder the data before building the HTML markup.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜