function onlyDirectChildren(node, collection){ var theChildren = []; for(var i = 0; i < collection.length; i++){ if(collection[i].parentNode === node)theChildren.push(collection[i]); } return theChildren; } if(!('rows' in HTMLTableElement.prototype))Object.defineProperty( HTMLTableElement.prototype, 'rows', { get: function(){ return onlyDirectChildren(this, this.getElementsByTagName('tr')); } } ); if(!('tBodies' in HTMLTableElement.prototype))Object.defineProperty( HTMLTableElement.prototype, 'tBodies', { get: function(){ return onlyDirectChildren(this, this.getElementsByTagName('tbody')); } } ); if(!('rows' in HTMLTableSectionElement.prototype))Object.defineProperty( HTMLTableSectionElement.prototype, 'rows', { get: function(){ return onlyDirectChildren(this, this.getElementsByTagName('tr')); } } ); if(!('cells' in HTMLTableRowElement.prototype))Object.defineProperty( HTMLTableRowElement.prototype, 'cells', { get: function(){ return onlyDirectChildren(this, this.querySelectorAll('th,td')); } } );