复习
三个取整函数
Math.ceil(1.4) 2 天花板 往高了取
Math.floor(1.01) 1 地板 往小了取
Math.round() 四舍五入函数 1.5 2动画的原理:
盒子位置 = 盒子当前的样式 + 步长- 以前 offsetLeft 现在 所有的样式 内嵌 外链
ie obj.currentStyle
window.getComputedStyle(obj, null);
1 function fun(obj,attr)
2 {
3 if(obj.currentStyle)
4 { return obj.currentStyle[attr];
5 } else {
6 return window.getComputedStyle(obj,null)[attr]}
7 }
8
json
两种声明方式
1. 对象声明 var json = {width:100,height:100}
2. 数组声明
var man = [ // 数组的 json
{
name:"刘德华",
age : 16,
address: "香港"
},
{
name:"张学友",
age: 33,
address: "澳门"
},
{
name:"黎明",
age: 55,
address: "大陆"
}
];
for(var i=0;i<man.length;i++)
{
console.log(man[i].name);
}
旋转原理:
每次点击 按钮, 他们的json 数值就更换就可以了.
删除和添加数组
pop() 删除最后一个
shift() 删除第一个
push() 追加 添加到最后面
unshift() 添加到 第一个位置
把最后一个json 删除,并且把最后一个添加到json 第一个位置
json.unshift(json.pop());
json.pop() 删除最后一个元素
console.log(json.pop()) 返回最后一个值
案例
。。。