Skip to content

Instantly share code, notes, and snippets.

@adamstac
Created June 3, 2011 15:38
Show Gist options
  • Save adamstac/1006548 to your computer and use it in GitHub Desktop.
Save adamstac/1006548 to your computer and use it in GitHub Desktop.
Create, show, and hide grid toggle with jQuery
$(document).ready(function() {
// Create, show, and hide grid toggle
$('body').append('<div id="grid"></div>');
$('body').append('<a href="#" class="toggle-grid"><span class="show">Show Grid</span><span class="hide">Hide Grid</span></a>');
$('a.toggle-grid').toggle(function() {
$('#grid').slideDown('fast');
$('.toggle-grid .hide').show();
$('.toggle-grid .show').hide();
}, function() {
$('#grid').slideUp('slow');
$('.toggle-grid .hide').hide();
$('.toggle-grid .show').show();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment