The Code object represents an HTML <code> element.
We can create a <code> element via the document.createElement()
method:
var x = document.createElement("CODE");
Click the button to create a CODE element with some text.
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button><br><br> <script> function myFunction() {//from w w w . ja va2 s . c o m var x = document.createElement("CODE"); var t = document.createTextNode("CSS HTML"); x.appendChild(t); document.body.appendChild(x); } </script> </body> </html>