为什么加了rsort功能后 图片显示不出来了 addPhotoes功能就不起作用添加图片了;没加rsort就行
<script type="text/javascript">
//generic function to get selector
function g(selector){
var method=selector.substr(0,1)=='.'?'getElementsByClassName':'getElementById';
return document[method](selector.substr(1));
}
//output all photoes
var data=data;
function addPhotoes(){
var template=g("#wrap").innerHTML;
var html=[];
for(var s=0; s<data.length;s++){
var _html=template
.replace('{{index}}',s)
.replace('{{img}}',data[s].img)
.replace('{{caption}}',data[s].caption)
.replace('{{desc}}',data[s].desc);
html.push(_html);
}
g("#wrap").innerHTML=html.join("");
//rsort(1);
}
addPhotoes();
//sort photoes
function rsort(n){
var photo-center=g("#photo_" + n);
photo-center.className+=" photo-center";
}
</script>