Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #7892
| Message-ID | <1460484.mR14RZRZF0@PointedEars.de> (permalink) |
|---|---|
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| Organization | PointedEars Software (PES) |
| Date | 2011-10-31 11:50 +0100 |
| Subject | Re: Changing letters in boxes |
| Newsgroups | comp.lang.javascript |
| References | <1cb16076-87c8-4bc6-8007-1efddfb7530b@s10g2000yqa.googlegroups.com> <j8ji7m$fj8$1@dont-email.me> <3024323.SPkdTlGXAF@PointedEars.de> <48b611a8-825b-49cf-bff1-e786e15f7361@f3g2000pri.googlegroups.com> |
| Followup-To | comp.lang.javascript |
Followups directed to: comp.lang.javascript
RobG wrote:
> Thomas 'PointedEars' Lahn wrote:
>> A safer approach is to remove all cells of the row except one, then
>> replace the content of the first cell and add more cells:
>>
>> var tr = document.getElementById("box");
>> var firstChild = tr.firstChild;
>> while (tr.lastChild != firstChild)
>> {
>> tr.removeNode(tr.lastChild);
>> }
>>
>> tr.cells[0].innerHTML = a;
>
> You seem to be assuming here that the firstChild of the tr will be a
> cell (TD or TH), when it may be a text node:
ACK
> […]
> To get the first cell, better to be explicit:
>
> var firstCell = tr.cells[0];
ACK
> An alternative is getElementsByTagName('td')[0], but the cells can be
> TH or TD, using the cells collection deals with both.
A viable alternative alternative are the `firstElementChild' and
`lastElementCild' properties if they are available.
> [...]
>> When all you know is jQuery, every problem looks $olvable.
>
> <grin> is that one of yours?
Yes :) It occurred to me when reading from John-David Dalton (@jdalton, on
Twitter) that the jQuery Standards Group (sic!) he recently joined is going
to suggest adding Array methods to NodeLists because they see so much
[].forEach.call(hostObject) etc. these days. Of course, my answer was – the
fact aside that this would make the DOM API language-dependent – that in a
well-developed Web application you seldom ever need [].….call(hostObject) to
begin with.
> 1. http://msdn.microsoft.com/en-us/library/ms533897%28v=VS.85%29.aspx
Thanks a lot, for some reason I had to rely on long-forgotten table-
scripting experience with MSHTML and third-party information regarding this.
It is acceptable to see this quirk being officially documented at last.
In fact, when you read on to [1] they are saying in the "Creating and
Manipulating Tables" section that the `innerHTML' and `innerText' properties
are *read-only* for `table' and `tr' objects, which makes kind of
Microsoftish sense considering the quirks and their proprietary table object
model. This would mean it is not only unwise to use `innerHTML' there, but
that it was functionally impossible.
PointedEars
___________
[1] <http://msdn.microsoft.com/en-us/library/ms532998(VS.85).aspx>
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Changing letters in boxes fulio pen <fuliopen@yahoo.com> - 2011-10-30 05:26 -0700
Re: Changing letters in boxes "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2011-10-30 15:08 +0200
Re: Changing letters in boxes fulio pen <fuliopen@yahoo.com> - 2011-10-30 07:14 -0700
Re: Changing letters in boxes fulio pen <fuliopen@yahoo.com> - 2011-10-30 10:22 -0700
Re: Changing letters in boxes "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2011-10-30 20:14 +0200
Re: Changing letters in boxes fulio pen <fuliopen@yahoo.com> - 2011-10-30 12:27 -0700
Re: Changing letters in boxes Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-10-30 18:58 +0100
Re: Changing letters in boxes Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-10-30 19:07 +0100
Re: Changing letters in boxes Andrew Poulos <ap_prog@hotmail.com> - 2011-10-31 06:15 +1100
Re: Changing letters in boxes Lasse Reichstein Nielsen <lrn.unread@gmail.com> - 2011-11-01 17:17 +0100
Re: Changing letters in boxes Andrew Poulos <ap_prog@hotmail.com> - 2011-11-02 07:10 +1100
Re: Changing letters in boxes Andreas Bergmaier <andber93@web.de> - 2011-11-01 23:37 +0100
Re: Changing letters in boxes Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-11-02 00:20 +0100
Re: Changing letters in boxes Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-11-01 18:01 +0100
Re: Changing letters in boxes Matt McDonald <matt@fortybelow.ca> - 2011-10-30 17:42 -0600
Re: Changing letters in boxes Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-10-31 02:19 +0100
Re: Changing letters in boxes Matt McDonald <matt@fortybelow.ca> - 2011-10-31 21:29 -0600
Re: Changing letters in boxes Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-11-01 11:52 +0100
Re: Changing letters in boxes RobG <rgqld@iinet.net.au> - 2011-10-30 19:33 -0700
Re: Changing letters in boxes "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2011-10-31 08:37 +0200
Re: Changing letters in boxes Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-10-31 11:50 +0100
Re: Changing letters in boxes faqir <faqir@faqir.com> - 2011-11-03 23:20 +0200
csiph-web