数组:一组数据的集合,数组中的数据可以是任何类型。
定义时间:new Date(),true
第一种定义:var arr=new Array();
第二中:var arr=['1','a',new Date(),true];
数字的方法:push()
arr.push('zhangsan','lisi');给数组中追加数据,返回数组的长度
//pop()
arr.pop()删除数组中最后一个数组,返回被删除的数据
//shift()
arr.shift()//删除数组中第一个数组,返回被删除的数据
//unshift()
arr.unshift('aa','tt')//在数组头部追加数据,可以追加多个
//splice(起始位置,个数,追加的值)
arr.splice(1,2,3,4,5);//向从数组中添加删除项目,然后返回被删除的项目。
Math.ceil(x) 向上取整
Math.floor(x) 向下取整
Math.max(x,y) 取最大值
Math.min(x,y) 取最小值
Math.random(); 取随机数,一般取0-1之间的数
Math.round(x) 四舍五入
arr.sort()排序
//操作方法
a='3.1415926';
alert(Math.ceil(a));向上取整
alert(Math.random()*35)//去随机数(含小数)
alert(Math.ceil(Math.random()*35))//去随机数(不含小数,向上取整)
元素的偏移量
offsetTop //获取盒子距离上边距的距离
offsetLeft //获取盒子距离左边距的距离
offsetHeight //获取盒子的高度 包含边框
offsetWidth //获取盒子宽度 包含边框
//写法
var box=document.getElementById('div');
console.log(box.offsetTop);
console.log(box.offsetLeft);
console.log(box.offsetHeight);
console.log(box.offsetWidth);
//client获取客户端的宽高
//获取内容的宽高不包含边框
console.log(box.clientWidth);
console.log(box.clientHeight);
//添加滚动条
overflow:scroll;//css样式
//scroll获取滚动区域的大小
console.log(box.scrollTop);
console.log(box.scrollLeft);
console.log(box.scrollWidth);
console.log(box.scrollHeight);
//onscroll滚动事件
widnow.οnscrοll=function(){
console.log(document.body.scrollTop);滚动条距离顶部的距离
}
定义时间:new Date(),true
第一种定义:var arr=new Array();
第二中:var arr=['1','a',new Date(),true];
数字的方法:push()
arr.push('zhangsan','lisi');给数组中追加数据,返回数组的长度
//pop()
arr.pop()删除数组中最后一个数组,返回被删除的数据
//shift()
arr.shift()//删除数组中第一个数组,返回被删除的数据
//unshift()
arr.unshift('aa','tt')//在数组头部追加数据,可以追加多个
//splice(起始位置,个数,追加的值)
arr.splice(1,2,3,4,5);//向从数组中添加删除项目,然后返回被删除的项目。
Math.ceil(x) 向上取整
Math.floor(x) 向下取整
Math.max(x,y) 取最大值
Math.min(x,y) 取最小值
Math.random(); 取随机数,一般取0-1之间的数
Math.round(x) 四舍五入
arr.sort()排序
//操作方法
a='3.1415926';
alert(Math.ceil(a));向上取整
alert(Math.random()*35)//去随机数(含小数)
alert(Math.ceil(Math.random()*35))//去随机数(不含小数,向上取整)
元素的偏移量
offsetTop //获取盒子距离上边距的距离
offsetLeft //获取盒子距离左边距的距离
offsetHeight //获取盒子的高度 包含边框
offsetWidth //获取盒子宽度 包含边框
//写法
var box=document.getElementById('div');
console.log(box.offsetTop);
console.log(box.offsetLeft);
console.log(box.offsetHeight);
console.log(box.offsetWidth);
//client获取客户端的宽高
//获取内容的宽高不包含边框
console.log(box.clientWidth);
console.log(box.clientHeight);
//添加滚动条
overflow:scroll;//css样式
//scroll获取滚动区域的大小
console.log(box.scrollTop);
console.log(box.scrollLeft);
console.log(box.scrollWidth);
console.log(box.scrollHeight);
//onscroll滚动事件
widnow.οnscrοll=function(){
console.log(document.body.scrollTop);滚动条距离顶部的距离
}