数组,元素的偏移量,client获取客户端的宽高,添加滚动条,onscroll滚动事件

数组:一组数据的集合,数组中的数据可以是任何类型。
定义时间: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);滚动条距离顶部的距离
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值