Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #7891
| From | "Jukka K. Korpela" <jkorpela@cs.tut.fi> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Changing letters in boxes |
| Date | 2011-10-31 08:37 +0200 |
| Organization | A noiseless patient Spider |
| Message-ID | <j8lfo1$n75$1@dont-email.me> (permalink) |
| 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> |
1.10.2011 4:33, RobG wrote:
> MS documentation explicitly says not to use innerHTML to modify
> tables[1].
Then I would recommend just putting id attributes on each <td> and
changing the cell contents. Any practical risk of making the cell update
operation divisible that way must be ignorable when compared with the
risks caused by added complexity of code.
But if an indivisible operation is really needed, then the simplest
approach that avoids the IE bug is probably something like this:
function addCell(row,data) {
var cell = document.createElement('td');
cell.innerHTML = data;
row.appendChild(cell);
}
function letters(a,b,c) {
var boxId = 'box';
var box = document.getElementById(boxId);
var newRow = document.createElement('tr');
newRow.id = boxId;
addCell(newRow,a);
addCell(newRow,b);
addCell(newRow,c);
box.parentNode.replaceChild(newRow,box);
}
> An alternative is getElementsByTagName('td')[0], but the cells can be
> TH or TD, using the cells collection deals with both.
No, all the three cells are <td> elements. If the real intent is to
create something easily modifiable and extensible, then you might worry
about the optimal way of retrieving all cells, or all data cells, in a
table row, and looping through them, but the problem posed was specific
and simple.
--
Yucca, http://www.cs.tut.fi/~jkorpela/
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