Click on a word to make all the other ones disappear:

One
Two
Three
Four


The Code (fresh off the presses, displaying what was used above):

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <script type="text/javascript" src="http://peter-ajtai.com/jquery/jquery-1.4.2.min.js"></script>
  5. </head>
  6. <body>
  7. <h2>Click on a word to make all the other ones disappear:</h2>
  8. <div id="one">One</div>
  9. <div id="two">Two</div>
  10. <div id="three">Three</div>
  11. <div id="four">Four</div><br/><br/>
  12. <input type="button" value="Show all" />
  13. <script type="text/javascript">
  14. var divs = $('#one, #two, #three, #four');
  15. divs.click(function ()
  16. {
  17. divs.not(this).slideUp('slow');
  18. });
  19. $('input').click(function ()
  20. {
  21. divs.slideDown('slow');
  22. });
  23. </script>
  24. <h2>The Code (fresh off the presses, displaying what was used above):</h2>
  25. <?php
  26. include_once "../php/codify-function.php";
  27. // Show code ##################################################################
  28. codify(file_get_contents(__FILE__), 'javascript');
  29. ?>
  30. </body>
  31. </html>