EDIT - I have now got a working counter for the right answer and done exactly the same for wrong answers but cannot get it working. It will not count more than one - http://jsfiddle.net/smilburn/Dxxmh/33/
I am creating a spelling game for children where empty spaces are highlighted in a grid and clues are given to spell the word correctly by clicking the corresponding letters on the side of the grid.
If you get the word right the space in the grid fades away with the use of "wordglow2". If you get it wrong it glows red with "wordglow4".
In my spelling game I want to count the number of right and wrong attempts of the words, and then show them at the end.
I have created a div in the HTML called "counter" Which should display the correct answers, but after 1 correct answer it doesn't keep count.
Here is the script
var completeLetters = $('.wordglow2').length;
var threeLetter = (completeLetters / 3);
var rightWords = $(threeLetter).length;
$('.counter').text(rightWords).show();
if (threeLetter == 3) {
$('table').fadeOut(2000);
}
I have tried to create a variable called "rightWord" that takes the length of the "threeLetter" and then displays it through the counter. It counts up to 1 then stops.
var threeLetter = (completeLetters / 3);
threeLetter
is number
var rightWords = $(threeLetter).length;
here you trying to select number
This game contain errors and it crash my browser, but count is working in this demo: http://jsfiddle.net/Dxxmh/29/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With