Take the 2-minute tour ×
<table class="display" id="jquerytable">
      <th>Eng 1</th>
      <th>Eng 2</th>
    <% foreach (var item in Model) { %>
      <td><%= Html.Encode(item.BillingAddress) %></td>
      <td><%= Html.Encode(item.DeliveryAddress) %></td>
      <td><%= Html.Encode(item.Engineer1Id) %></td>
      <td><%= Html.Encode(item.Engineer2Id) %></td>
    <% } %>

How can I hide th Eng 1 and Eng 2? I try wit visible = "false" but not successful.

share|improve this question
If you give the item a class or ID then in jQuery (which I assume you are using from the jquerytable reference) you can hide it with $("#myId").hide() or $(".myClass").hide() –  Alistair Jul 12 '10 at 8:50
add comment

2 Answers

up vote 1 down vote accepted

MattMitchell is mostly right; you really want to use:

<th style="visibility: hidden;">

The difference between display: none; and visibility: hidden; is that none takes the element out of the document flow and visibility just hides it. So by using hidden, the possibility that you get weird layout effects is reduced.

share|improve this answer
add comment

You want to use

<th style="display: none;">

Alternatively a class:

.hide { display: none; }

<th class="hide">

You'll want to make sure this class or style is on both the <th> and the corresponding <td>

If you want to toggle visibility with jQuery you can apply a class to both the <th> and the <td> (e.g. "engcol") and then use .toggle() like so:

share|improve this answer
add comment

Your Answer


