Javascript examples for DOM HTML Element:Code
You can create a <code> element by using the document.createElement() method:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">create a CODE element with some text</button><br><br> <script> function myFunction() {//from w w w. j a v a 2 s . co m var x = document.createElement("CODE"); var t = document.createTextNode("this is a test"); x.appendChild(t); document.body.appendChild(x); } </script> </body> </html>