Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #18321
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsreader4.netcologne.de!news.netcologne.de!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail |
|---|---|
| Content-Type | text/plain; charset="UTF-8" |
| Message-ID | <8973725.hmDRQCkskN@PointedEars.de> (permalink) |
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| Reply-To | Thomas 'PointedEars' Lahn <usenet@PointedEars.de> |
| Organization | PointedEars Software (PES) |
| Date | Sun, 03 Feb 2013 02:03:49 +0100 |
| User-Agent | KNode/4.8.5 |
| Content-Transfer-Encoding | 8Bit |
| X-Face | %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&.<b';Md8`dH6iqhT)6C^.Px|[=M@7=Ik[_w<%n1Up"LPQNu2m8|L!/3iby{-]A+#YE}Kl{Cw$\U!kD%K}\2jz"QQP6Uqr],./"?;=4v |
| Face | iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEXTxa4RFk5dUWANED8PFEfy7+MGBiW+n3ZNF/QuAAACaElEQVQ4jVXUwVOcMBQG8Dc7Rc4PUntdWV2uxjDpGaGeozOp1woar4jd5t/v9wLstMwsA/ntlxdCAgUc1hjTc9/JCZfGoo3wG3HdmdAWrIJRHe7GM/TmpY5VFefuVcAkkPbLIaN8rmPmjloyZxgyR3GuJ4K0AGtJ2htz8o7yqikm759fldQXaMpbDzjKAG+8v+AugVTOPO5DOjLvGtUYQwh0CPjnVMyGd+8/GfUB5nLKJDD2aLDh5HYyMDJGDwQIo2ZmZcKbowNmAdB/AzyFhrmF2MHRb0QJJfaAnwGB6orZhoykLzJtGwF/xpYxI1dswomiUj3gTuAIqCn/4C7cULwGNBtwMTk3Y4LfKB5YUaOKBKYtpplm7u0vip8tU1NWWyI/7XdcSuIDoMt6rVHMWT0DbjHPGqDqZVSa6zleLcUTcIKLoMv3ueJluALtAo9B302zPPlrtiVScRdCjXvVh3e3JpYa/jjkuC9N+LrBMlz/eAN4eQijX2EdLo6c5tGGHwLyHFtXk89dDGHwCVhG9T0S/j55AhRZgkMCmUQXJ49TnS1wnQDvw0eAh9ICeMmEFbCnPMFzjAvsWoEWEFdYEx+S0MoUZ1gT1wId8+AF3Bl2OoEu906AUHx5VLw/gXYg/x84loOah/2UYNrgiwSwGO7RfUzVBbx/kgpckumGOi6QirtD6gkLTitbnxNol47S2jVc2vsN5kPqaAHT8uUdAJM4v/DanjYOwmUjWznGfwB7sGtAtor5BgofDuzaRj4kSQAqDakTsKORa3Q3xKi3gE1fhl71KRMqrdZ2AWNNg/YOhQyrVBnb+i+nEg4bsDA+egAAAABJRU5ErkJggg== |
| Subject | Re: <span> text replacement ?? |
| Newsgroups | comp.lang.javascript |
| References | <an5bvtFgkc7U1@mid.individual.net> <kejvc0$mvf$1@dont-email.me> <WNWdnR8vB9CaEZDMnZ2dnUVZ_r2dnZ2d@westnet.com.au> |
| MIME-Version | 1.0 |
| Lines | 63 |
| NNTP-Posting-Date | 03 Feb 2013 02:03:50 CET |
| NNTP-Posting-Host | 97e5cb81.newsspool4.arcor-online.net |
| X-Trace | DXC=ZX[9HCI7UTWV;Ef1`Jk54\4IUK<Cl32<Q4Fo<]lROoRQ8kF<OcfhCO[0bK78=TXjm^DZm8W4\YJN\b@mF9jNikdUWWB88<dh9WUJJbZlVg\S8X |
| X-Complaints-To | usenet-abuse@arcor.de |
| Xref | csiph.com comp.lang.javascript:18321 |
Show key headers only | View raw
Andrew Poulos wrote:
> On 3/02/2013 8:10 AM, Jukka K. Korpela wrote:
>> 2013-02-02 22:41, Mel Smith wrote:
>>> I wish to change the textual content of the following <span>
>>> element.
>>>
>>> <span id="ierrmsg">This is original error msg</span>
>>>
>>> I have tried document.getElementById("ierrmsg").value ="new error
>>> msg" ;
>>>
>>> .. and I've also tried to do .nodeValue, .text, etc.
>>
>> Normal elements don’t have such properties.
Nonsense.
>> The practical choice is the innerHTML property:
>> document.getElementById("ierrmsg").innerHTML = "new msg" ;
>
> or
>
> document.getElementById("ierrmsg").firstChild.nodeValue = "new msg";
>
> should also work. Of course the element would have to exist before you
> can apply any change to it.
Neither the “innerHTML” property nor the “nodeValue” property of the first
text child node are usually equivalent to the *text* content of the
corresponding element. Per W3C DOM Level 3 Core, all elements have a
“textContent” property that can be read from and assigned to.
document.getElementById("ierrmsg").textContent = "new msg";
It is supported by many DOM implementations, but not MSHTML < 9. For the
latter, you need to remove all child nodes and create a new text child node:
if (typeof el.textContent != "undefined")
{
el.textContent = text;
}
else
{
while (el.lastChild) el.removeChild(el.lastChild);
el.appendChild(document.createTextNode(text));
}
See also jsx.dom.setTextContent().
An assignment to the “innerHTML” property is not equivalent to that because
there the value right-hand side will be parsed, and the property is not
available in XML mode.
<http://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-textContent>
<https://developer.mozilla.org/en-US/docs/DOM/Node.textContent>
<http://msdn.microsoft.com/en-us/library/ff974773.aspx>
--
PointedEars
Twitter: @PointedEars2
Please do not Cc: me. / Bitte keine Kopien per E-Mail.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
<span> text replacement ?? "Mel Smith" <med_cutout_syntel@aol.com> - 2013-02-02 13:41 -0700
Re: <span> text replacement ?? "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2013-02-02 23:10 +0200
Re: <span> text replacement ?? Andrew Poulos <ap_prog@hotmail.com> - 2013-02-03 08:58 +1100
Re: <span> text replacement ?? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-02-03 00:51 +0100
Re: <span> text replacement ?? Jim T. <x@y.z> - 2013-02-03 12:03 -0500
Re: <span> text replacement ?? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-02-04 01:47 +0100
Re: <span> text replacement ?? Eric Bednarz <bednarz@fahr-zur-hoelle.org> - 2013-02-04 22:40 +0100
Re: <span> text replacement ?? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-02-03 02:03 +0100
Re: <span> text replacement ?? "Mel Smith" <med_cutout_syntel@aol.com> - 2013-02-02 18:28 -0700
Re: <span> text replacement ?? "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2013-02-03 07:49 +0200
Re: <span> text replacement ?? Andrew Poulos <ap_prog@hotmail.com> - 2013-02-03 21:08 +1100
Re: <span> text replacement ?? "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2013-02-03 07:45 +0200
Re: <span> text replacement ?? Andrew Poulos <ap_prog@hotmail.com> - 2013-02-03 21:11 +1100
Re: <span> text replacement ?? "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2013-02-03 15:38 +0200
Re: <span> text replacement ?? Andrew Poulos <ap_prog@hotmail.com> - 2013-02-04 06:56 +1100
Re: <span> text replacement ?? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-02-03 22:35 +0100
Re: <span> text replacement ?? Christoph Becker <cmbecker69@gmx.de> - 2013-02-04 02:08 +0100
Re: <span> text replacement ?? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-02-04 02:35 +0100
Re: <span> text replacement ?? Eric Bednarz <bednarz@fahr-zur-hoelle.org> - 2013-02-04 22:54 +0100
Re: <span> text replacement ?? "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2013-02-05 00:12 +0200
Re: <span> text replacement ?? Andrew Poulos <ap_prog@hotmail.com> - 2013-02-06 11:42 +1100
Re: <span> text replacement ?? "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2013-02-06 07:50 +0200
Re: <span> text replacement ?? Andrew Poulos <ap_prog@hotmail.com> - 2013-02-06 17:36 +1100
Re: <span> text replacement ?? Eric Bednarz <bednarz@fahr-zur-hoelle.org> - 2013-02-09 00:46 +0100
Re: <span> text replacement ?? Christoph Becker <cmbecker69@gmx.de> - 2013-02-04 02:21 +0100
csiph-web