simple DOM change

Sample changing the content of the DOM

by Justin Harker

HTML

<!-- Business Web Technologies     -->
<!-- School of Information Systems -->
<!-- Curtin University             -->

<!-- Division for content -->
<div id="content">
</div>

JavaScript

// Minimum of two numbers
function minimum(a, b) {
  if (a < b)
    return a;
  else
    return b;
}

// Try this:
// Can you edit this JavaScript so that you show the
// minimum of two numbers stored in variables that you
// can will call x and y?

var newContent = "Minimum of 12 and 6 is " + minimum (12, 6);
document.getElementById("content").innerHTML = newContent;