title: Add a class to the catch statement
body: <p>I have a problem when I try to add a class in the catch statement.</p>
  
  <p>When I click the button to confirm, javascript show me the error with the class successfully added, but when I reclick the button, without refreshing the page, the class added is no longer present.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function catchclass(){
      var result, x;
      result = document.getElementById("result");
      result.innerHTML = "";
      x = document.getElementsByTagName("input")[0].value;
      try { 
          if(x == "")  throw "is Empty";
      }
      catch(err) {
          result.innerHTML = "Input " + err;
          result.className += 'error';
      }
  }</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>p.error {
      background: red;
      padding: 10px;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;input type="text" /&gt;
  &lt;button type="button" onclick="catchclass()"&gt;Test Input&lt;/button&gt;
  
  &lt;p id="result"&gt;&lt;/p&gt;</code></pre>
  </div>
  </div>
  </p>