Javascript examples for DOM HTML Element:Pre
You can create a <pre> element by using the document.createElement() method:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">create a PRE element</button> <script> function myFunction() {/*from w w w . j av a2s . co m*/ var x = document.createElement("PRE"); var t = document.createTextNode("This is a preformatted text."); x.appendChild(t); document.body.appendChild(x); } </script> </body> </html>