Combine HTML tags with a DOM text node element?

R

Robert Oschler

I have several text nodes that I create on the fly in my web page use
document.createTextNode().

Is there an easy way using DOM techniques to add formatting tags like <b>,
<H2>, etc. to my text node, without having to create extra nodes for every
little detail? Is there a better technique?

Thanks.
 
M

Martin Honnen

Robert said:
Is there an easy way using DOM techniques to add formatting tags like <b>,
<H2>, etc. to my text node, without having to create extra nodes for every
little detail? Is there a better technique?

If you are scripting HTML documents then most browsers around now
support the innerHTML property of elements to be set to a snippet of
HTML markup which the browser then parses and inserts as the content of
the element.
innerHTML is not a W3C DOM property but IE 4 introduced it and now
Mozilla, Opera, Safari, Konqueror do too.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top