How to hide an HTML table, and collapse it?

Hello dear experts.

 I have an HTML table on my web page. Under certain circumstances, I would like to hide the table and collapse it. When I say collapse it, I mean that it will not occupy any visible space on the html page when it is viewed on the screen.

I know that there are various collapsible panel crontrols out there. However I am looking for a more simple solution for hiding the html table and taking away the visible space it occupies.

I am also open to using Java Script or JQuery to achieve what I want. However if I could stick to an html or css solution for hiding/removing/collapsing the Html table, that would be simpler.
LVL 2
brgdotnetcontractorAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RobOwner (Aidellio)Commented:
depending on how you trigger the table disappearing you use add "table-invisible" class to the table and apply the following css:

.table-invisible {
    display: none;
}

Open in new window

0
RobOwner (Aidellio)Commented:
Mouse over the red table in this example to watch it disappear among the content

http://jsbin.com/iYiTEZa/1/edit
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RobOwner (Aidellio)Commented:
html:

<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
  <table>
    <div>this is a div with lots of stuff in it</div>
    <tr>
      <td>cell</td>
      <td>cell</td>
      <td>cell</td>
    </tr>
  </table>
  <div>hi, i am after the table</div>
</body>
</html>

Open in new window


css:
table {
  border: 1px solid black;
  width: 300px;
  height: 400px;
  background-color: red;
}

.table-invisible {
  display: none;
}

Open in new window


javascript:
$('table').on('mouseover',function() {
  $(this).addClass('table-invisible');
});

Open in new window

0
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
Here is a little different spin http://jsbin.com/edekOpi/2/edit

<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
  <button id="showhide"  value="hide">Hide</button>
  <table id="myTable">
    <tr><td>stuf</td></tr>
  </table>
</body>
</html>

Open in new window


$('#showhide').click(function(){
  if ($(this).val()=="hide"){
    $('#myTable').hide();
    $(this).val("show");
    $('#showhide').text("Show");
  }else{
    $('#myTable').show();
    $(this).val("hide");
    $('#showhide').text("Hide");
  }
  
});

Open in new window

0
brgdotnetcontractorAuthor Commented:
Thank you
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTML

From novice to tech pro — start learning today.