Skip to content

Instantly share code, notes, and snippets.

@remi
Created October 4, 2012 14:51

Revisions

  1. remi created this gist Oct 4, 2012.
    9 changes: 9 additions & 0 deletions helpers.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    // Helpers
    $.fn.isPresent = function() { return this && this.length > 0 }
    $.fn.isBlank = function() { return typeof(this) == "undefined" || !this || (this && this.length == 0) }

    // Examples
    $("body").isPresent() // => true
    $("#foo").isPresent() // => false
    $("body").isBlank() // => false
    $("#foo").isBlank() // => true