JavaScript / JQuery: Set element visibility

Below are functions to set visibility of an element through JavaScript for JQuery Element.

Set element’s visibility

function SetElementVisibility(id, visibility)
{
    if (visibility == 'visible')
        $('#' + id).show();
    else if (visibility == 'hidden')
        $('#' + id).hide();
}

Set visibility of element’s parent. Usually use to set the containing <div> tag’s visibility.

function SetContainerVisibility(id, visibility)
{
    if (visibility == 'visible')
        $('#' + id).parent().show();
    else if (visibility == 'hidden')
        $('#' + id).parent().hide();
}
Advertisements
JavaScript / JQuery: Set element visibility

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s