8/16 超炫画廊总结
创建前端模板,结合数组 把页面画廊更新到页面,
elem.id.splt("_")[1]
split 分割字符串,遇到_分割,返回数组
(/photo_center/).test(cls) 正则表达式
检测 cls 里 有没有字符串photo_center 有则返回true 没有返回false
function g(id){
var method=id.substr(0,1)=="."
?"getElementsByClassName"
:"getElementById";
return document[method](id.substr(1));
}
通用函数
id.substr(0,1) 第一个参数为 index,第二个参数为length 返回字符串
splice(index,length)
分割数组,
var a=[1,2,3,4,"ccc"];
var b=a.splice(2,2);
a // [1,2,"ccc"]
b// [3,4]