title: Change color of span tag depending on value
body: <p>
  I want to change the color of the <code>message</code> variable in the following HTML:</p>
  
  <pre><code>&lt;span id="mess" style="visibility:visible;"&gt;
                  &lt;text id="tex"&gt;{{ message }}&lt;/text&gt;
  &lt;/span
  </code></pre>
  
  <p>I am using Jinja2 together with Flask - Python to pass a value to the <code>{{ message }}</code>
  variable. Here is how I tried to do it:</p>
  
  <pre><code>$(document).ready(function(){
  
              if (document.getElementById('tex').value == 'Message sent !')
              {
                  document.getElementById('tex').setAttribute("style", "color:green;");
              }
              else
              {
                  document.getElementById('tex').setAttribute("style", "color:red;");
              }
  });
  </code></pre>
  
  <p>The result of the <code>document.getElementById('tex').value</code> is always <code>undefined</code> and the color of the text of the <code>message</code> variable is always red.</p>
  
  <p>Is there a way with which I can accomplish that ? Thank you in advance.</p>