_______________________________________________________________________________Click MeThis text toggles when Click Me is clicked.//实现对象的style动态的变化。document.getElementById(“toggle”).style.display=’non… _______________________________________________________________________________
<script type="text/javascript"> <!-- functionswitchMenu(obj) { var el = document.getElementById(obj); if ( el.style.display != "none" ) { el.style.display = 'none'; } else { el.style.display = ''; } }
functionhide(){ document.getElementById("toggle").style.display='none'; } //--> </script> <body onload="hide();"> <a onclick="switchMenu('toggle');" title="Test">Click Me</a><br><div id="toggle">This text toggles when Click Me is clicked.</div>