jQuery.deepShow()

Wednesday, May 22, 2013

I wrote this little snippet earlier today that ensures an object is shown even if one of its parent objects is currently being hidden. It does this, of course, by going through its parents and checking for the 'display:none' property..

/// <summary>
/// Shows the object and clears any style="display:none;" /// styles on all of its parents.
/// </summary>
jQuery.fn.deepShow = function() {
    $(this).parents().each(function() {
        if ($(this).css("display") === "none") {
            $(this).css("display", "");
        }
    });
    $(this).show();
}
Older Post Home Newer Post