Skip to content

Instantly share code, notes, and snippets.

@daifu
Forked from adamstac/grid-toggle.js
Created July 7, 2012 18:11
Show Gist options
  • Save daifu/3067512 to your computer and use it in GitHub Desktop.
Save daifu/3067512 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