Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. $(document).ready(function()
  2. {
  3. $(".box-img").click(function()
  4. {
  5. var itemid = '#div' + $(this).attr('target');
  6.  
  7. //Show the element if nothing is shown.
  8. if ($('.active').length === 0) {
  9. $(itemid).slideDown();
  10. $(itemid).addClass('active');
  11.  
  12. //Hide the element if it is shown.
  13. } else if (itemid == "#" + $('.active').attr('id')) {
  14. $('.active').slideUp();
  15. $(itemid).removeClass('active');
  16.  
  17. //Otherwise, switch out the current element for the next one sequentially.
  18. } else {
  19. $('.active').slideUp(function () {
  20. $(this).removeClass('active');
  21. if ($(".targetDiv:animated").length === 0) {
  22. $(itemid).slideDown();
  23. $(itemid).addClass('active');
  24. }
  25. });
  26. }
  27.  
  28. });
  29.  
  30. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement