jQuery showHide() Extension

Clicking to either show or hide something gets coded all the time, and it's a nause, so here is a one line jQuery extension to toggle show/hide.

1. Smash this piece of javascript in your header or somewhere useful:

$.fn.extend({ showHide: function() { if ($(this).is(':visible')) $(this).hide('slow'); else $(this).show('slow'); }});


2. ...it extends jQuery so that you can do:

onClick='$("#someDivOrSimilar").showHide();'

Comments

Popular posts from this blog

Installing LAMP Apache/MySQL/PHP on Chromebook/Chromebox

Installing Ubuntu Linux on your ChromeBox/ChromeBook

Changing your Mac OSX Terminal's default text editor