On Dec 20, 2:25 am, David McFarland <[EMAIL PROTECTED]> wrote:
> > Don't forget that every row has rowIndex and sectionRowIndex
> > properties and every cell a cellIndex property. These are very much
> > faster than CSS-style selectors, e.g.:
>
> > $($('#tableID').rows[x].cells[y]).text();
Sorry, that should have been:
$($('#tableID')[0].rows[x].cells[y]).text();
>
> Hi Rob,
>
> I've never seen that syntax before, and I can't get it to work. Do you
> have a working example you can show us?
<table id="fred">
<tr><td>sally<td>Sam
</table>
<script type="text/javascript" src="jquery.js"></script>
<script>
alert( $($('#fred')[0].rows[0].cells[0]).text() );
</script>
But I screwed up my speed test, that is actually no faster than using
a CSS style selector. The fast way is:
<script>
function getText(el){
if (typeof el.textContent == 'string') return el.textContent;
if (typeof el.innerText == 'string') return el.innerText;
}
alert( getText(document.getElementById('fred').rows[0].cells[0]) );
</script>
--
Rob