1. Home
  2. Computing & Technology
  3. JavaScript

Concentration Memory Game With Images

2. Head Script

clr gif
More of this Feature

Introduction Body Script

The script for the memory game is in three parts. The first two part go in the head section of your web page. The first step is to select the code from the text box below (there is a highlight all button beneath it to make this easier) and copy it into a file called memoryh.js.

You will need to edit the entries for back and tile to change the values to refer to your images. Just remember to edit the images in your graphics program so that they are all 60 pixels square so that they don't take too long to load (the combined size of the 16 images used for my example is just 4758 bytes so you should have no problem keeping the total under 10k).

Next select the code from the text box below and copy it into a file called memory.css.

You next attach these into the head section of your page.

<script type="text/javascript" src="memoryh.js">
</script>
<link rel="stylesheet" href="memory.css" type="text/css" />

Now all that remains is to add the body script where you want the game to appear.

Sample Page | Head Script | Body Script
Explore JavaScript
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. JavaScript

©2009 About.com, a part of The New York Times Company.

All rights reserved.