In my code I have added this variable
var spellSpace = $('td[data-word=' + listOfWords[rndWord].name + ']').hasClass('.highlight-problem:not(.right-word)');
and for some reason it will not work in this code
$('.next-question').click(function () {
$('td').removeClass('highlight-problem');
var r = rndWord;
while (r == rndWord) {
rndWord = Math.floor(Math.random() * (listOfWords.length));
}
$('td[data-word="' + listOfWords[rndWord].name + '"]').addClass('highlight-problem');
$('td[data-word=' + word + ']').removeClass('wrong-letter').removeClass('wrong-word').removeClass('right-letter');
var spellSpace = $('td[data-word=' + listOfWords[rndWord].name + ']').hasClass('.highlight-problem:not(.right-word)');
if (spellSpace) {
addMedia();
}
});
It just will not return the addMedia() function and I do not know why
Can anyone show me where I am going wrong?
hasClassgets a class name as an argument, not a selector. You may useis()instead:Or maybe the following: