title: Add style to element's blank innerHTML using javascript
body: <p>I have a form with different radio inputs. Each represents an answer to a question. I want to turn the correct answer green on the click of a button. The correct answer is passed as a Flask variable {{}}. I select all input fields and save them in elements. Then I filter out the correct one with a loop and store it in results. When the button is clicked, the function 'clicked' executes and it is supposed to change the results style. Unfortunatelly the console tells me, that results is undefined. I checked the innerHTML and it is blank. The problem is possibly that the innerHTML is a flask variable and not hard-coded. Does anyone have an idea, how I can change the adequate input fields style?  </p>
  
  <pre><code>{% extends "layout.html" %}
  {% block body %}
  
  {% if cq == -1 %}
      &lt;h3&gt;Great, all questions where answered.&lt;/h3&gt;
      &lt;a href=" {{ url_for('index') }} "&gt;Go back.&lt;/a&gt;
  {% else %}
      &lt;h3&gt;Question number {{ cq+1 }}:&lt;/h3&gt;
      &lt;p id="quest"&gt;{{ myVariable.q }}&lt;/p&gt;
      &lt;form action="/quiz" method="GET"&gt;
          &lt;input type="radio" name="answer" value="a"&gt;{{ myVariable.a }}&lt;/input&gt;&lt;/br&gt;
          &lt;input type="radio" name="answer" value="b"&gt;{{ myVariable.b }}&lt;/input&gt;&lt;/br&gt;
          &lt;input type="radio" name="answer" value="c"&gt;{{ myVariable.c }}&lt;/input&gt;&lt;/br&gt;
          &lt;input type="radio" name="answer" value="d"&gt;{{ myVariable.d }}&lt;/input&gt;&lt;/p&gt;
          &lt;input type="hidden" name="cq" value="{{ nq }}"/&gt;
          &lt;input type="hidden" name="pq" value="{{ cq }}"/&gt;
          &lt;br/&gt;
          &lt;input type="submit" value="Check &amp; goto next question"&gt;
      &lt;/form&gt;
  &lt;button type="button" onclick="clicked()"&gt;My Button&lt;/button&gt;
  {% endif %}
  
  &lt;br/&gt;&lt;br/&gt;
  
  {% if pq_correct &gt;= 0 %}
  &lt;h3&gt;Check of your previous answer:&lt;/h3&gt;
  {% endif %}
      {% if pq_correct == 1 %}
      &lt;p&gt;TOP! Your previous Answer was correct.&lt;/p&gt;
  {% elif pq_correct == 0 %}
      &lt;p&gt;Sorry! Your previous Answer was &lt;b&gt;not&lt;/b&gt; correct.
      &lt;a href="?cq={{ pq }}"&gt;Try again (goto previous question)&lt;/a&gt;
      &lt;/p&gt;
  {% endif %}
  &lt;p&gt; Correct answers: {{ count }}&lt;/p&gt;
  
  &lt;script&gt;
      window.onload = function() {
          var rightAnswer = '{{ answerVar }}';
          console.log(rightAnswer);
          elements = document.getElementsByTagName("input");
          console.log(elements[0].innerHTML);  // blank
          elements[0].innerHTML = "Test";  // doesn't appear
  
          var results = [];
          for(var x = 0; x &lt; elements.length; x++)
              if(elements[x].value == rightAnswer)
                  results.push(elements[x]);
          console.log(results);
      };
  
      function clicked(rightAnswer){
          // set correct answer green
          // results[0].innerHTML.style.color = "green"; // console - "results not defined"
          alert('It should work, why doesn\'t it work?');
  
      };
  &lt;/script&gt;
  {% endblock %}
  </code></pre>