$.post('module/json/scenicSpotText.json',function(res){ $.each(res.data,function(i,o){ let ii = i + 1; if(ii%3 == 1){ o.place = 'left'; }else if(ii%3 == 2){ o.place = 'middle'; }else if(ii%3 == 0){ o.place = 'right'; } }); //定位排序 $.each(res.data,function(i,o){ if(o.place == 'left'){ $('.js-left').each(function(){ let _index = $(this).index(); $(this).css({ "left":0, "top": _index/3 * 362 }); }); }else if(o.place == 'middle'){ $('.js-middle').each(function(){ let _index = $(this).index(); if(_index == 1){ $('.js-middle').css({ "left":340, "top": 0 }) }else{ $(this).css({ "left":340, "top": parseInt((_index-1)/3) * 435 }); } }); }else if(o.place == 'right'){ $('.js-right').each(function(){ let _index = $(this).index(); if(_index == 2){ $('.js-right').css({ "right":0, "top": 0 }) }else{ $(this).css({ "right":0, "top": parseInt((_index-1)/3) * 362 }); } }); } }); });