Get Code Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Code


The Code object represents an HTML <code> element.

You can access a <code> element by using getElementById():

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<code id="myCode">test</code>

<button onclick="myFunction()">set the color of the code element to red</button>

function myFunction() {//ww w .j av  a2  s .co m
    var x = document.getElementById("myCode"); = "red";


Related Tutorials