title: How to print just the table data element using JavaScript in asp.net?
body: <p>I want to print a particular table data element.  </p>
  
  <p>The table structure is as follows.  </p>
  
  <pre><code>| Table No | Table Code | Description | Action |
       4           8785        abc         Print
       5           7463        cde         Print
       6           5645        fgh         Print
  </code></pre>
  
  <p>I want to print the elements of just the first two columns(Table No,Table Code) of a row when I click on the Print link.</p>
  
  <p>The javascript code below prints the whole row.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      function Print(a) {
          alert("heloo");
          var row = $(a).closest("tr").clone(true);
          var printWin = window.open('', '', 'left=0", ",top=0,width=1000,height=600,status=0');
          var table = $("[id*=tableCodeTable]").clone(true);
          $("tr", table).not($("tr:first-child", table)).remove();
          table.append(row);
          $("tr td:last,tr th:last", table).remove();
          var dv = $("&lt;div /&gt;");
          dv.append(table);
          printWin.document.write(dv.html());
          printWin.document.close();
          printWin.focus();
          printWin.print();
          printWin.close();
      }
  &lt;/script&gt;  
  </code></pre>
  
  <p>The html code for print link </p>
  
  <pre><code>&lt;a href="javascript:;" onclick="Print(this)"&gt;Print&lt;/a&gt;
  </code></pre>
  
  <p>The html code for table</p>
  
  <pre><code>&lt;table border="2px" id="tableCodeTable" class="table"&gt;
    &lt;tr&gt;
          &lt;th&gt;
              Table No
          &lt;/th&gt;
          &lt;th&gt;
              Table Code
          &lt;/th&gt;
          &lt;th&gt;
              Description
          &lt;/th&gt;         
          &lt;th&gt;
              Action
          &lt;/th&gt;
      &lt;/tr&gt;
      &lt;tbody&gt;
   &lt;% foreach (var item in Model.Mapping)
   {%&gt;   
     &lt;tr id="&lt;%=item.Id%&gt;"&gt;
  
          &lt;td id="no_&lt;%=item.Id%&gt;" class="two"&gt;
               &lt;input type="hidden" value=" &lt;%=item.Id%&gt;"/&gt;
              &lt;%=item.TableNo%&gt;
          &lt;/td&gt;
          &lt;td&gt;
              &lt;%=item.TableCode%&gt;
          &lt;/td&gt;
        &lt;td id="dc_&lt;%=item.Id%&gt;" class="twoo"&gt; 
             &lt;%=item.Description%&gt;
         &lt;/td&gt;          
          &lt;td&gt;      
               &lt;a href="javascript:;" onclick="Print(this)"&gt;Print&lt;/a&gt;
          &lt;/td&gt;
    &lt;/tr&gt;            
   &lt;% } %&gt;
   &lt;/tbody&gt;   
  &lt;/table&gt;
  </code></pre>
  
  <p>How can I print just those two elements? Please Help.</p>