Guest User

Untitled

a guest
Jan 21st, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. var $jslide = jQuery.noConflict();
  2.  
  3. $jslide(document).ready(function() {
  4.  
  5. // initialise the visibility check
  6. var is_visible = false;
  7.  
  8. // append show/hide links to the element directly preceding the element with a class of "toggle"
  9. $jslide('.toggle').prev().append(' <a href="#" class="toggleLink">'+showText+'</a>');
  10.  
  11. // hide all of the elements with a class of 'toggle'
  12. $jslide('.toggle').hide();
  13.  
  14. // capture clicks on the toggle links
  15. $jslide('a.toggleLink').click(function() {
  16.  
  17. // switch visibility
  18. is_visible = !is_visible;
  19.  
  20. // change the link depending on whether the element is shown or hidden
  21. $jslide(this).html( (!is_visible) ? showText : hideText);
  22.  
  23.  
  24. // toggle the display - uncomment the next line for a basic "accordion" style
  25. //$('.toggle').hide();$('a.toggleLink').html(showText);
  26. $jslide(this).parent().next('.toggle').toggle('slow');
  27.  
  28.  
  29. // return false so any link destination is not followed
  30. return false;
  31.  
  32. });
  33. });
Add Comment
Please, Sign In to add comment