Posted By

soxiam on 03/27/07


Tagged

jquery collapse expand


Versions (?)

Who likes this?

16 people have marked this snippet as a favorite

jonhenshaw
Jaymoon
Hirmine
penguin999
zeno
ryno
vali29
stavelin
martingoldszein
esquareda
demixo
drwitt
marnold2000
vkolev
bobbym245
ringo380


jquery collapse expand


 / Published in: Other
 

  1. INSIDE THE HEAD
  2. ......................................................................
  3.  
  4. <script type="text/javascript" src="jquery.js"></script>
  5. <script type="text/javascript">
  6. $(function()
  7. {
  8.  
  9. $("#trigger").click(function(event) {
  10. event.preventDefault();
  11. $("#box").slideToggle();
  12. });
  13.  
  14. $("#box a").click(function(event) {
  15. event.preventDefault();
  16. $("#box").slideUp();
  17. });
  18. });
  19. </script>
  20.  
  21.  
  22. HTML
  23. ......................................................................
  24.  
  25. <a href="#" id="trigger">TRIGGER</a>
  26.  
  27. <div id="box">
  28. <a href="#" class="close">[x]</a>
  29. <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren</p>
  30. </div>
  31.  
  32. CSS
  33. ......................................................................
  34. #box {
  35. display: none;
  36. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: jonhenshaw on July 12, 2007

This was exactly what I was looking for. Perfect!

Posted By: deusignis on September 10, 2007

Cool thing. What would I have to write, if I wanted the box to load collapsed?

Posted By: JREAM on August 7, 2008

Thanks this is great, Here is it without the "X" since I found that unnecessary

$(function() {

$("#trigger").click(function(event) { event.preventDefault(); $("#upload-box").slideToggle(); });

});

This was my html: TRIGGER

You need to login to post a comment.