Home > Article > Web Front-end > Examples of common functions for multiple layer switching effects implemented in javascript_javascript skills
The example in this article describes the common function of multiple layer switching effects implemented in javascript. Share it with everyone for your reference. The specific implementation method is 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 is the id and name of the control layer clicked by the mouse divId, divName is the id and name of the layer controlled to be displayed and hidden zDivCount is the number of displayed and hidden layers - 1 (if it is 5 layer is 4)
tagclass and divclass are the style of the control layer and the style of the controlled layer respectively
I hope this article will be helpful to everyone’s JavaScript programming design.