-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuntitled.js
More file actions
52 lines (51 loc) · 1019 Bytes
/
untitled.js
File metadata and controls
52 lines (51 loc) · 1019 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
function listToArray(likeArray){
var ary=[];
try{
ary=[].prototype.slice.call(likeArray,0)
}catch(e){
for (var i = 0; i < likeArray.length; i++) {
ary[ary.length]=likeArray[i];
};
}
return ary;
}
function getIndex(ele){//元素索引
var index = 0;
var p = ele.previousSibling;
while(p){
if(p.nodeType===1){
index++;
}
p=p.previousSibling;
}
return index;
}
function offset(ele){
var l=ele.offsetLeft;
var t= ele.offsetTop;
var p=ele.offsetParent;
while(p){
if(window.navigator.userAgent.indexOf("MSIE 8")>=0){
l+=p.offsetLeft;
t+=p.offsetTop;
}else{
l+=p.offsetLeft+p.clientLeft;
t+=p.offsetTop+p.clientTop;
}
p=p.offsetParent;
}
return {left:l,top:t}
}
function getWin(attr,value){
if(typeOf value === "undefined"){
return document.documentElement[attr]||document.body[attr];
}
document.documentElement[attr]===value;
document.body[attr]=value;
}
function getCss(curEle,attr){
var val = null;
try{
val = window.getComputedStyle(curEle,null)[attr];
}
}