在我的節目,我都稱爲類「正確的答案,我想在TD類,但我有它真正的麻煩。配售類
這是我加上‘正確的字’類 「spellWord」,但我如何將它添加到 「TD」 類代替。
var spellWord = $('.highlight-problem .drop-box');
if (!spellWord.filter(':not(.occupied)').length) {
var wordIsCorrect = 0;
spellWord.each(function() {
if ($(this).parents('td').data("letter") == $(this).find("div").data("letter")) {
console.log('letter is: ' + $(this).find("div").data("letter"))
wordIsCorrect++;
}
});
console.log(spellWord.length + ' , ' + wordIsCorrect);
if (spellWord.length == wordIsCorrect) {
spellWord.addClass('right-word');
$(right).css('visibility', 'visible');
$(wrong).css('visibility', 'hidden');
score.right++;
$('.score').html(score.right + "/2").show();
setTimeout(function() {
successSound.play();
}, 200);
我已經試過的東西等。
spellWord.addClass('td').addClass('right-word');
和
$('.td').addClass('right-word');
但似乎無法得到它的工作。小提琴:http://jsfiddle.net/smilburn/Dxxmh/93/