Main >> Desktop software development discussions>> Javascript div manipulation
Wednesday, January 24 2007 02:58 AM
function toggleLayer(whichLayer,displ) { if (document.getElementById) { // this is the way the standards work var style2 = document.getElementById(whichLayer).style; style2.display = style2.display? "":displ; //style2.display = style2.display? "":"block"; } else if (document.all) { // this is the way old msie versions work var style2 = document.all[whichLayer].style; style2.display = style2.display? "":"block"; } else if (document.layers) { // this is the way nn4 works var style2 = document.layers[whichLayer].style; style2.display = style2.display? "":"block"; } } AND dont forget </script> <style> div#divpreview { display: none; } div#divcomment { display: block; } </style> <div id="divcomment" ></div> <div id="divpreview" ></div> then use these functions toggleLayer('divpreview','block'); toggleLayer('divcomment','none');
reply