ga-wdi-exercises / project1

[project] GA- Project 1
3 stars 75 forks source link

Problem with button #290

Closed malrese1 closed 7 years ago

malrese1 commented 7 years ago

Card not changing color when i answer a question

//What happens If the answer is right or wrong function checkAnswer() { console.log(); event.preventDefault(); var userGuess = $(this).siblings().find('input[type=text]').val()

if ( userGuess === answer ) {
  document.getElementById("objects").style.backgroundColor = '#18D213';
}
else { document.getElementById("objects").style.backgroundColor = '#E81806';
console.log(document);
}

}

jsm13 commented 7 years ago

It looks like you're using jQuery for the first bit and then vanilla JS to set the background color.

I would stick with one or the other, then in the first line of checkAnswer use either $(selector) or document.querySelector(selector) to target the card and assign the result to a variable (eg card). Then console.log(card) and make sure you have the right element targeted.