EDIT**
In my word game there is a grid with 3 letter words.
The aim of the game is to spell the words by clicking on the corresponding letters
If I understand the question, you are looking for a way to check the validity of a word that is created by selecting letters, and then applying styles to the word.
Heres what I would do:
var dict = []; // Create an array with all of the possible words
var word = "";
function createWord(){ // Creates the variable word to be checked against array
var addToWord = $(this).html(); // Sets the variable addTo Word to the letter selected
word = word + addToWord; // Adds the selected letter to the current word
};
function checkWord(){
var i = dict[].length; // Sets incrementor "i" to the length of the array
while (i){ // While "i" is a positive value
if (word == dict[i]){ // Checks if the word is equal to the word in that spot of the array
// If it is, apply the correct styles
}
else{ // If it isn't,
// Do Nothing
}
i = i--; // Decrease i by one, and repeat until the whole array has been checked
}
};
$('foo bar').click(function(){
createWord();
checkWord();
}
Good Luck! Hope this helps.
-Brian