title: how to pass dynamically the element id and call a javascript function?
body: <p>I have javascript code like below - </p>
  
  <pre><code>function initPage(){
  
      // Left Navigation Pane - moverOver effect:
      document.getElementById("imgHowToBuy").onmouseover = leftNavHoverIn;
      document.getElementById("imgNewAddition").onmouseover = leftNavHoverIn; 
      document.getElementById("imgMostPopular").onmouseover = leftNavHoverIn;
      document.getElementById("imgOffer").onmouseover = leftNavHoverIn;   
      document.getElementById("imgRecentlySold").onmouseover = leftNavHoverIn;
  .....
  }
  </code></pre>
  
  <p>Basically my code works (the function gets called and executes beautifully). But I dont think I am using the principles of best practice here. It looks a little wierd to keep calling the same function; can i somehow pass the id of the element as the argument, and then execute the function, so that this whole thing reduces to a single line of code?</p>
  
  <p>I'm a self taught js guy :D</p>
  
  <p>Thanks!</p>