TIP: Inserting rows in html table via innerHTML or .html() is not valid in some browsers (similar IE9), and using .append("<tr></tr>") is not good suggestion in any browser. best and fastest way is using the pure javascript codes.
for combine this way with jQuery, only add new plugin similar this to jQuery:
$.fn.addRow=function(index/*-1: add to end or any desired index*/, cellsCount/*optional*/){ if(this[0].tagName.toLowerCase()!="table") return null; var i=0, c, r = this[0].insertRow((index<0||index>this[0].rows.length)?this[0].rows.length:index); for(;i<cellsCount||0;i++) c = r.insertCell(); //you can use c for set its content or etc return $(r); };
And now use it in whole the project similar this:
var addedRow = $("#myTable").addRow(-1/*add to end*/, 2);