This is a fragment of (*non-working*) code that illustrates the key concepts in creating JavaScript code that writes HTML. The key concepts are: (a) A class: OptionX() from which you create objects (b) A function, OptionX_over that gets attached to each object (c) A prototype declaration, OptionX.prototype.over, that attaches it (d) A loop that calss "new OptionX" to create the objects function OptionX(document, label) { //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this.highlighted = false; // Mouse is not over icon now var n = document.images.length; // for 1st object, n=0 document.write( ' ' + ' > ' + '