Advertisement
Guest User

HTML show/hide real use test

a guest
Jun 18th, 2012
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title></title>
  4. <script type="text/javascript">
  5. function showHide(shID) {
  6.     var exDiv = document.getElementById(shID);
  7.     if(exDiv.getAttribute("data-visible") != 'false'){
  8.          document.getElementById(shID+'-show').style.cssText = ';height:auto;opacity:1;visibility:visible;';  
  9.          document.getElementById(shID).style.cssText = ';height:0;opacity:0;visibility:hidden;';  
  10.          exDiv.setAttribute("data-visible" , 'false');
  11.     } else {
  12.          document.getElementById(shID+'-show').style.cssText = ';height:;opacity:0;visibility:hidden;';  
  13.          document.getElementById(shID).style.cssText = ';height:auto;opacity:1;visibility: visible ;';   
  14.           exDiv.setAttribute("data-visible" , 'true');
  15.     }
  16. }
  17. </script>
  18.  
  19. <style type="text/css">
  20. #ExampleDIV {
  21.     height: 0;
  22.     opacity: 0;
  23.     visibility: hidden;
  24.     -webkit-transition: all 300ms ease-in-out;
  25.     -moz-transition: all 300ms ease-in-out;
  26.     -ms-transition: all 300ms ease-in-out;
  27.     -o-transition: all 300ms ease-in-out;
  28.     transition: all opacity 300ms ease-in-out;
  29. }
  30. </style>
  31. </head>
  32. <body>
  33.  
  34.  
  35. <a href="" class="ShowLink" id="ExampleDIV-show" onclick="showHide('ExampleDIV');return false;">Show the Content</a>
  36.  
  37. <div id="ExampleDIV" data-visible="false">
  38.     <p>Some example content</p>
  39.     <a href="" class="HideLink" id="ExampleDIV-hide" onclick="showHide('ExampleDIV');return false;">Hide the Content</a>
  40. </div>
  41.  
  42.  
  43. </body>
  44. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement