Tuesday, November 24, 2015

Use Jquery to hide all elements except one

I need to hide everything, except the table with id = divShowOnly
View JS Fiddle Source Here

Code:

// hide all elements except a few
//hideAllExcept('#ctl00_PlaceHolderMain_gvSummary')
function hideAllExcept(selectrId) {
//$('body > :not(#ctl00_PlaceHolderMain_gvSummary)').hide();
    //$('[id*=gvSummary]').appendTo('body');
   
    $('body > :not(' + selectrId + ')').hide();
    $('[id*=' + selectrId + ']').show(); //or  appendTo('body');
   
}

No comments:

Post a Comment