Re: Changing text between <div>' s
"Ton den Hartog" <ton.den.hartog .removespam@ton h.net> writes:
PLEASE don't top post.
[color=blue][color=green]
>> document.getEle mentById('t').f irstChild.nodeV alue="Hello";[/color]
>
> That works. But what if I want a HTML element in the tag. When I use
> "Hello<br>world " I get a LITERAL <br> in my browser-screen !! :-( How can I
> prevent that ?[/color]
If you want to use DOM methods;
var t = document.getEle mentById("t");
// clear content
while(t.hasChil dNodes()) {
t.removeChild(t .lastChild);
}
// add new content:
t.appendChild(d ocument.createT extNode("Hello" ));
t.appendChild(d ocument.createE lement("br"));
t.appendChild(d ocument.createT extNode("World" ));
Search for the W3C DOM 2 specification to read more about dynamic
document manipulation.
/L
--
Lasse Reichstein Nielsen - lrn@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
"Ton den Hartog" <ton.den.hartog .removespam@ton h.net> writes:
PLEASE don't top post.
[color=blue][color=green]
>> document.getEle mentById('t').f irstChild.nodeV alue="Hello";[/color]
>
> That works. But what if I want a HTML element in the tag. When I use
> "Hello<br>world " I get a LITERAL <br> in my browser-screen !! :-( How can I
> prevent that ?[/color]
If you want to use DOM methods;
var t = document.getEle mentById("t");
// clear content
while(t.hasChil dNodes()) {
t.removeChild(t .lastChild);
}
// add new content:
t.appendChild(d ocument.createT extNode("Hello" ));
t.appendChild(d ocument.createE lement("br"));
t.appendChild(d ocument.createT extNode("World" ));
Search for the W3C DOM 2 specification to read more about dynamic
document manipulation.
/L
--
Lasse Reichstein Nielsen - lrn@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Comment