title: In IE8, add a new row before the last row to HTML table using Jquery
body: <p>I need to add a new row before the summary row to a table. I able to add a new row before summary row but the problem is some cells have text field elements and some are non-editable. How to create a row taken this into consideration.
   Please find below the code for adding a new row before the last row.</p>
  
  <pre><code>&lt;table id="sampTable"&gt;
        &lt;thead&gt;
          &lt;tr&gt;
              &lt;td&gt;Column 1&lt;/td&gt;
              &lt;td&gt;Column 2&lt;/td&gt;
              &lt;td&gt;Column 3&lt;/td&gt;
              &lt;td&gt;Column 4&lt;/td&gt;
              &lt;td&gt;Column 5&lt;/td&gt;
            &lt;/tr&gt;
        &lt;/thead&gt;
        &lt;tbody&gt;
           &lt;tr&gt;
                &lt;td&gt;&lt;input type="text"/&gt;&lt;/td&gt;
                &lt;td&gt;&lt;input type="text"/&gt;&lt;/td&gt;
               &lt;td&gt;&lt;input type="text"/&gt;&lt;/td&gt;
               &lt;td&gt;&lt;/td&gt;
               &lt;td&gt;&lt;/td&gt;
           &lt;/tr&gt;
            &lt;tr id="summaryRow"&gt;
                &lt;td&gt;&lt;input type="text"/&gt;&lt;/td&gt;
                &lt;td&gt;&lt;input type="text"/&gt;&lt;/td&gt;
               &lt;td&gt;&lt;input type="text"/&gt;&lt;/td&gt;
               &lt;td&gt;&lt;/td&gt;
               &lt;td&gt;&lt;/td&gt;
           &lt;/tr&gt;
        &lt;/tbody&gt;
      &lt;/table&gt;
      &lt;br&gt;
  
      &lt;button id="AddBtn" onclick="addTableRow($('#sampTable'));"&gt;Add row&lt;/button&gt;
  &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script&gt;
   function addTableRow(jQtable){
          jQtable.each(function(){
              var $table = $(this);
              // Number of td's in the last table row
              var n = $('tr:last td', this).length;
              var tds = '&lt;tr&gt;';
              for(var i = 0; i &lt; n; i++){
                  tds += '&lt;td&gt;&lt;input type="text" class="tb-input"/&gt;&lt;/td&gt;';
              }
              tds += '&lt;/tr&gt;';
             if($('tbody', this).length &gt; 0){
                 // $('tbody', this).append(tds);
                 $('tr:last',this).before(tds);
              }else {
                  $(this).append(tds);
              }
          });
    }
  &lt;/script&gt;
  </code></pre>
  
  <p>The above code adds a text field element for all the columns. I don't need it, as for me some columns contain text fields and some are non-editable.</p>