慕标3810760
2016-06-02 06:04
<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>
rsort里面的photo-center变量不能这么写,改成photo_center
CSS3+JS 实现超炫的散列画廊特效
46091 学习 · 215 问题
相似问题