為什么加了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>
2016-06-06
rsort里面的photo-center變量不能這么寫,改成photo_center