日期:2014-05-16 浏览次数:20358 次
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="jquery.js" type="text/javascript"></script>
<script>
$(document).ready(function(){
$('#loading').load('后台处理数据的.php');
})
</script>
<script type="text/javascript">
window.onload = function () {
var divTestJQ = $("#divContainer"); //取得容器对象
var divJQ = $(">div.divframe", divTestJQ); //取容器需要重排的对象
var EntityList = []; //定义一个数组用于存放要排序的对象
divJQ.each(function () {
var thisJQ = $(this);
EntityList.push({ Name: parseInt(thisJQ.attr("name"), 10), JQ: thisJQ }); //把要排序的对象和排序的值一起放到一个新的对象里,并存入到数组
});
EntityList.sort(function (a, b) { //利用数组的排序方法重新排序对象
return a.Name - b.Name; //从小到大
});
for (var i = 0; i < EntityList.length; i++) {
EntityList[i].JQ.appendTo(divTestJQ); //把排序完的对象重新插入到容器对象
};
};
</script>
<style type="text/css">
.divframe{
padding:10px;margin:5px;border:1px solid #ccc;
}
</style>
</head>
<body>
<span id="loading"></span>
</body>
</html>
<div id="divContainer">
<div name='1358988132' class = 'divframe'>1<br>
<div style = 'padding:10px;margin:5px;border:1px solid #ccc'>1</div>
</div>
<div name='1358968219' class = 'divframe'>2<br><div style = 'padding:10px;margin:5px;border:1px solid #ccc'>2</div>
</div>
<div name='1355785403' class = 'divframe'>3<br>
<div style = 'padding:10px;margin:5px;border:1px solid #ccc'>3</div>
</div>
<div name='1355630287' class = 'divframe'>4<br>
<div style = 'padding:10px;margin:5px;border:1px solid #ccc'>4</div>
</div>
<div name='1347463733' class = 'divframe'>19 &l