I'm teaching myself jQuery by writing the game of memory (where you turn tiles over two at a time, looking for matches).
I have 16 img tags, each representing one of the tile faces. I have an array of 16 jpg file names. I want to set the src attribute of each img tag to a random selection from my array. To do so, I wrote a function that extracts a string from the array, removes the string from the array, and returns the string. I then use this function in the onReady handler this way:
$('.picture').attr( {src : extractArrayValue(cousinPictures)});
This seems to work, except that it appears that the function extractArrayValue appears to be called only once across all 16 tags. All 16 img tags get the same image, but if I refresh the page they get a different same 16 image files.
Am I correct about what's happening? And, if so, is there a straightforward way to force extractArrayValue to get called for each attribute that gets set?