javascript implementation of multiple layer switching effects generic function instances

  • 2020-07-21 06:53:14
  • OfStack

An example of javascript's implementation of a common function for multi-layer switching effects is described. Share to everybody for everybody reference. Specific implementation methods are as follows:


function ChangeDiv(tagId,tagName,divId,divName,zDivCount,tagclass,divclass) {
for(i=0;i<=zDivCount;i++) {
document.getElementById(divName+i).style.display="none";
document.getElementById(divName+i).className='';
document.getElementById(tagName+i).className='';
}
document.getElementById(divName+divId).style.display="block";
document.getElementById(tagName+tagId).className=tagclass;
document.getElementById(divName+divId).className=divclass;
}

tagId,tagName are id and name divId for the mouse-clicked control layer,divName are id and name zDivCount are the number of show and hide layers -1 (or 4 if there are 5 layers)

tagclass and divclass are the styles of the control layer and the controlled layer respectively

I hope this article has been helpful for your javascript programming.


Related articles: