Dynamically populate an element styled with white-space: pre | James Revillini

Dynamically populate an element styled with white-space: pre

Assume:

$ = document.getElementById;
pre = $(’pre-text-element’);  //pre-text-element is the ID of my pre tag element

You cannot use:

$(’element’).innerHTML = ‘line1\nline2′; //will not work in IE7

You must do this:

e = $(’element’);
while(kid=e.firstChild) { e.removeChild(kid) }  //remove all children in the
e.appendChild(’line1\nline2′);

Lame, huh?

"Dynamically populate an element styled with white-space: pre" was published on January 22nd, 2008 and is listed in javascript.

Follow comments via the RSS Feed | Leave a comment | Trackback URL

Leave Your Comment

james.revillini.com