function sort(e){ var el = (typeof e == "string")?$('#'+e):e; var h1 = []; /*左边一列的开始座标*/ var h2 = []; /*右边一列的开始座标*/ var box = el.find("li"); /*求和*/ Array.prototype.sum = function (){for (var sum = i = 0; i < this.length; i++)sum += parseInt(this[i]);return sum}; var getMin = function(){ var a = h1.sum();var b = h2.sum(); return (a<=b)?[1,a]:[2,b];} box.each(function(){ var o = $(this); /*获取当前高度*/ var h = o.outerHeight(true); var p = getMin(); if(p[0] == 1){ o.css('position', 'absolute').css('top', p[1]).css('left',0).find('.arrow').removeClass().addClass('arrow arrow-left'); h1.push(h); }else if(p[0] == 2){ o.css('position', 'absolute').css('top', p[1]).css('left','50%').find('.arrow').removeClass().addClass('arrow arrow-right'); h2.push(h); } tmph = el.outerHeight(true); if( Number(tmph) < Number (p[1] + h ) ){ el.css('height', (p[1] + h +20)); } }); }; //--------------------------------- function fetchComm(){ if(window.isFajax==true){return;} var page = 1; if(typeof window.pages=="undefined"){window.pages =1;} var page = window.pages; $.ajax({ url:'/api/api.asp?method=cht.comment.list&sn=0&w=cht&t=E&p='+page, type:'GET', dataType:'json', beforeSend : function(){window.isFajax=true;}, success:function(o){ var content = $('#commonList ul'); if(o.data.length){ for(var i=0;i'; Str += '
'+ Item.commentbody +'
'; content.append(Str); } window.isFajax=false; }else{ window.isFajax=true; } window.pages = page+1; sort("commonList"); } }); } $(function(){ $(window).resize(function(){ sort("commonList"); }); $(window).scroll(function(){ if(jQuery(window).height()+jQuery(window).scrollTop() + 300 > jQuery(document).height() ){ fetchComm(); } }); fetchComm(); });