//JavaScript Document Sunbye 1.0 //getElementById //function Start var$=function(_id) {returndocument.getElementById (_id)}; //function End //function Start functionByclass (classname) {if(Document.getelementsbyclassname) {//to determine if Firefox is a browser, you can also use document.all to determine whether IE returndocument.getelementsbyclassname (classname); }Else{ varTags=document.getelementsbytagname ("*"); varTagslength=tags.length; vargettags=[]; for(vari=0;i<tagslength;i++){ if(tags[i].classname==classname) {Gettags.push (tags[i]); } } returnGetTags; } } //function End //function Start functionInputsearch (tagid,prompttxt,colorfocus,colorblur) {TagID=document.getElementById (TagID); Tagid.value=Prompttxt; Tagid.style.color=Colorblur; Tagid.onfocus=function(){ if( This. value==prompttxt) { This. value= ""; This. style.color=Colorfocus; } }; Tagid.onblur=function(){ if( This. value== ""){ This. value=Prompttxt; Tagid.style.color=Colorblur; }Else{ This. style.color=Colorfocus; } }; } //function End //function Start functionFadeOut (ele,speed) {varele=document.getElementById (ele); varopacitynum=ele.style.opacity| | 1; varSpeed= (speed/100) | | 10;functionOpacityoff () {if(opacitynum>0) {ele.style.opacity=opacitynum= (opacitynum-0.01). toFixed (2); }Else{clearinterval (OPACITYT); } } varopacityt=setinterval (opacityoff,speed); } //function End //function Start functionFadeIn (ele,speed) {varele=document.getElementById (ele); varopacitynum=ele.style.opacity| | 0; varSpeed= (speed/100) | | 10;functionOpacityadd () {if(opacitynum<1) {ele.style.opacity=opacitynum= (parsefloat (opacitynum) +0.01). ToFixed (2); }Else{clearinterval (OPACITYT); } } varopacityt=setinterval (opacityadd,speed); } //function End //function Start functionHasclass (obj,cls) {returnObj.className.match (NewRegExp (' (\\s|^) ' + CLS + ' (\\s|$) ')); } functionaddclass (obj,cls) {if(! This. Hasclass (OBJ,CLS)) Obj.classname + = "" +CLS; } functionRemoveclass (obj,cls) {if(Hasclass (obj,cls)) {varreg=NewRegExp (' (\\s|^) ' +cls+ ' (\\s|$) '); Obj.classname=obj.classname.replace (Reg, "); } } //function End
Personal JS class Library Mycool