topical media & game development

talk show tell print

professional-javascript-10-CollapsibleSectionExample.htm / htm



  <html>
      <head>
          <title>Style Example</title>
          <script type="text/javascript">
              function toggle(sDivId) {
                  var oDiv = document.getElementById(sDivId);
                  oDiv.style.display = (oDiv.style.display == "none") ? "block" : "none";
              }
          </script>
      </head>
      <body>
          <div style="background-color: blue; color: white; font-weight: bold; padding: 10px; cursor: pointer"
               onclick="toggle('divContent1')">Click Here</div>
          <div style="border: 3px solid blue; height: 100px; padding: 10px"
               id="divContent1">This is some content
          to show and hide.</div>
          <p>&nbsp;</p>
          <div style="background-color: blue; color: white; font-weight: bold; padding: 10px; cursor: pointer"
               onclick="toggle('divContent2')">Click Here</div>
          <div style="border: 3px solid blue; height: 100px; padding: 10px"
               id="divContent2">This is some content
          to show and hide.</div>
      </body>
  </html>
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.