title: Why is the .setAttribute() and .removeAttribute methods not working in my javascript code?
body: <p>I've created a little flashcard game as shown below:</p>
  
  <p><img src="https://i.stack.imgur.com/JxWw7.jpg" alt="enter image description here"></p>
  
  <p>After a user enters a correct answer in the text box, the word "Correct!" is supposed to appear in the color green in bold font, and then the CSS attributes are supposed to be removed shortly afterwards.  Here is the HTML for the input area:</p>
  
  <pre><code>&lt;div&gt;
      &lt;input type="text" id="answer" style="width: 80%; height: 30px;" placeholder="Enter your answer..." onkeyup="checkAnswer(this,event);" autofocus&gt;&lt;br&gt;
  &lt;/div&gt;  
  </code></pre>
  
  <p>This is the corresponding javascript that is supposed to perform the action as described above:</p>
  
  <pre><code>function checkAnswer(input, event){
      if(event.keyCode == 13){
          var answer = document.getElementById("answer").value.toLowerCase();
          var answer_style = document.getElementById("answer");
          for(var i = 0; i&lt;qs.length; i++){
              if(answer == qs[cardIndex]["a"].toLowerCase()){
                  **input.setAttribute("style", "color:green; font-weight:bold;");**
                  input.value = "Correct!";
                  setTimeout(function(){input.value="";},1000);
                  **input.removeAttribute("style");**
              }else{
                  input.value = "Incorrect!";
                  setTimeout(function(){input.value="";},1000)
              }
          }
          if(input.value == "Correct!"){
              nextCard();
          }
      }
  }
  </code></pre>
  
  <p>Everything works in the checkAnswer function except the setAttribute and removeAttribute methods which have been starred in the code snippet.  I've tried placing the removeAttribute method after the for loop and that doesn't work.  If I don't include the removeAttribute method the setAttribute methods works, but I don't want the text to remain green.</p>
  
  <p>If anyone could help me out on this that would be great!</p>
  
  <p>If you need more information to understand the question don't hesitate to ask!</p>
  
  <p>Thank you!</p>