title: Change div background color on click event
body: <p>I am trying to change div color on click but it is not working:</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
          &lt;script&gt;
              function data(){
                  var MyDiv1 = document.getElementById('newdata').innerHTML;
                  alert(MyDiv1)   
                  if(MyDiv1==1) {
                      document.getElementsById('newdata').style.backgroundColor = "green";
                  }
              }
          &lt;/script&gt;
      &lt;/head&gt;
      &lt;body &gt;
          &lt;div id="newdata" style="background-color: red; width: 100px;height: 50px;"&gt;
              1
          &lt;/div&gt;
          &lt;a href="#" onclick="data();"&gt;Logout&lt;/a&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Where am I wrong here?</p>
  
  <p>Any help will be appreciated</p>