Show or hide a jQuery element given a condition

Posted . Visible to the public.

If you have jQuery code like this:

if (condition) {
  $element.show();
} else {
  $element.hide();
}

... you can shorten this to:

$element.toggle(condition);
Henning Koch
License
Source code in this card is licensed under the MIT License.
Posted by Henning Koch to makandra dev (2015-10-13 10:05)