Thanks, that's very clear.

JAS

On Feb 2, 10:25 pm, "Michael Geary" <m...@mg.to> wrote:
> That didn't work because .html is a method, not a property you can set. This
> would have a better chance of working:
>
>   $('#myTable tr:eq(4) td:eq(3)').html( 'new text' );
>
> But what was wrong with your original code? It looked fine to me (except for
> the "var oCell =" part - that doesn't look right, since it sounds like
> you're expecting oCell to be a reference to the column element when it will
> actually be the text string).
>
> And I suspect that the integer row and column numbers will probably not be
> hard coded numbers in the actual code, but variables, right? So your actual
> jQuery code might be something more like:
>
>   $( '#myTable tr:eq(' + y + ') td:eq(' + x + ')' ).html( text );
>
> Instead of all that, you could use jQuery just as a shortcut for the
> document.getElementById() call and keep the rest of your code. And since
> you're probably doing a number of jQuery and DOM operations on the table,
> let's cache the table's jQuery object and DOM element in a pair of
> variables:
>
>   var $myTable = $('#myTable'), myTable = $myTable[0];
>   // ...and later...
>   myTable.rows[y].cells[x].innerHTML = text;
>
> This is both simpler and cleaner than the :eq() selector, and it's likely to
> be much faster too.
>
> -Mike
>
> > From: JAS
>
> > Well I tried:
>
> > $("#myTable tr:eq(4) td:eq(3)").html = "new text";
>
> > and, while it gave no error, it also produced no result.
>
> > Any other ideas?
>
> > JAS
>
> > On Feb 2, 5:15 pm, ksun <kavi.sunda...@gmail.com> wrote:
> > > try $("#myTable tr:eq(4) td:eq(1)").html() for the 5th row and 2nd
> > > column
>
> > > On Feb 2, 5:46 am, JAS <james.sch...@gmail.com> wrote:
>
> > > > I am (very) new to jQuery, and I have what I think must
> > be a simple
> > > > question.
>
> > > > Without jQuery, I would write:
>
> > > > var oCell = document.getElementById('myTable').rows[5].cells
> > > > [2].innerHTML = "something new";
>
> > > > but I do not understand how to write this same line in jQuery.
>
> > > > Thanks to anyone who can help.
>
> > > > JAS

Reply via email to