/**
* Delete Array to specify subscript or specified object
*/
Array.prototype.remove=function (obj) {
for (var i =0;i <this.length;i++) {
var temp = this[i];
if (!isnan (obj)) {
Temp=i;
}
if (temp = = obj) {
for (var j = I;j <this.length;j++) {
THIS[J]=THIS[J+1];
}
This.length = this.length-1;
}
}
}
Use:
var aaa=new Array ();
Aaa[0]= "Rrrrr";
Aaa[1]= "BBB";
Aaa[2]= "BBBB";
Aaa[3]= "BBB";
Aaa.remove (2);//delete the element labeled 2
/**
Get 4 random numbers do not repeat//if data.length=100, the method is to get 0-100 random numbers
*/
function Getrandomnum (data) {
Randomly find four videos from all videos
var randomarray=new array ();//take 4 random numbers into the array
var j=0;
while (true) {
var randnum=parseint (Math.random () *data.length);
if (randomarray.length>0) {
if (Randnum!=randomarray[j-1]) {
Randomarray[j]=randnum;
j + +;
}
}else if (randomarray.length==0) {
Randomarray[j]=randnum;
j + +;
}
if (j==4) {
Break
}
}
return randomarray;
}
/**
* Get nested CSS style values
* @param {Object} obj
* @param {Object} attribute
* @return {TypeName}
*/
function GetStyle (obj, attribute) {
Return Obj.currentstyle? obj.currentstyle[attribute]/*ie*/
: Document.defaultView.getComputedStyle (obj, null) [ATTRIBUTE]/*IE9 firefox google */;
}
Use
GetStyle (document.getElementById ("mydiv"), "left");//Get absolute positioning of the left value, get the value with px