Skip to content

Instantly share code, notes, and snippets.

@joshuaogle
Created November 10, 2010 21:13
Show Gist options
  • Select an option

  • Save joshuaogle/671527 to your computer and use it in GitHub Desktop.

Select an option

Save joshuaogle/671527 to your computer and use it in GitHub Desktop.
Code used in JoshuaOgle.com and in an upcoming article on ID based reusable jquery for simple effects
/* Reusable Effects */
$('[id*=toggle-]').live('click',function() {
var container = $(this).attr("id").replace("toggle-","");
$('#'+container).toggle();
return false;
});
$('[id*=slide-]').live('click',function() {
var container = $(this).attr("id").replace("slide-","");
$('#'+container).slideToggle();
return false;
});
$('[id*=fade-]').live('click',function() {
var container = $(this).attr("id").replace("fade-","");
if ($('#'+container) .is(':hidden')) {
$('#'+container).fadeIn();
} else if ($('#'+container) .is(':visible')){
$('#'+container).fadeOut();
}
return false;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment