Implement the Toggle Visibility function - Show/Hide anything

. Tuesday, September 30, 2008
  • Agregar a Technorati
  • Agregar a Del.icio.us
  • Agregar a DiggIt!
  • Agregar a Yahoo!
  • Agregar a Google
  • Agregar a Meneame
  • Agregar a Furl
  • Agregar a Reddit
  • Agregar a Magnolia
  • Agregar a Blinklist
  • Agregar a Blogmarks

  1. Log in your Blogger account.
  2. From the Dashboard, go to Layout
  3. Choose Edit HTML
  4. Scroll down a bit or look for :
    </head>
  5. Immediately above that, copy/paste :
    <script language="javascript" type="text/javascript">
    function toggleVis( elemID )
    {    var elem = document.getElementById( elemID );
    	if( elem.style.display != 'none' )
            {        elem.style.display = 'none';
            }
            else
            {        elem.style.display = 'block';
            }
    }
    </script>
  6. Save your template.
  7. To use it, you just have to create a DIV and give it an ID. And then, create an instance which (e.g. on click) will invoke the 'toggle visibility' function of your DIV.
  8. Example :
    <a onclick="toggleVis('example');">
    Click here to toggle visibility of the following element</a> <div id="example">This is the element to be toggled</div>

    produces...
    Click here to toggle visibility of the following element
    This is the element to be toggled

0 comments:

.