title: Adding eventlisteners to if statement
body: <p>I am wondering if you can add <code>onmouseover</code> + <code>onmouseout</code> to an if/else statement in Javascript for example:</p>
  <pre><code>function pan() {
          var ID = document.getElementById(&quot;grad&quot;);
          var change = ID.style.backgroundSize = &quot;1200px 500px&quot;;
          var revert = ID.style.backgroundSize = &quot;1080px 300px&quot;;
  
          if (){
              change.addEventListener(&quot;onmouseover&quot;);
          }else {
              revert.addEventListener(&quot;onmouseout&quot;);
          }
  
      }
  </code></pre>
  <p>I have looked everywhere and cannot see a definite yes or no, unless its in jQuery, and I haven't even looked at jQuery yet so please don't give an answer in jQuery.</p>
  <p>If, it is possible, how do you do it?</p>
  <p>Else, whats the alternative?</p>