Javascript examples for DOM HTML Element:Code
The Code object represents an HTML <code> element.
You can access a <code> element by using getElementById():
<!DOCTYPE html> <html> <body> <code id="myCode">test</code> <button onclick="myFunction()">set the color of the code element to red</button> <script> function myFunction() {//ww w .j av a2 s .co m var x = document.getElementById("myCode"); x.style.color = "red"; } </script> </body> </html>