The Essential Guide to HTML5

(Greg DeLong) #1

CHAPTER 9


Code Explanation


for (j=0;j<alphabet.length;j++) { Iterates over all of the letters in the alphabet


uniqueid = "a"+String(j); Constructs the unique identifier


thingelem = document.getElementById
(uniqueid);


Gets the element

thingelem.removeEventListener('click',
pickelement,false);


Removes the event handling for this element

} Closes the j iteration


} Closes the cur test to determine if the
hanging is complete


} Closes the if (not) test (bad guess by
player)


var id = this.id; Extracts the identifier for this element


document.getElementById(id).style.display
= "none";


Makes this particular alphabet button
disappear

} Closes the function


Closes the script
Closes the head
Opening tag that sets up call to init

Hangman

Puts the name of game in big letters

Opening tag for paragraph
Opening tag for canvas element. Includes
dimensions.

Your browser doesn't support the HTML5
element canvas.


Message for people using browsers that don't
recognize canvas

Closing tag for canvas
Free download pdf