title: JS - How to add an onclick event to a div with parameter?
body: <p>I know how to add an onclick event to a div without parameter :</p>
  
  <pre><code>newDiv.onclick = selectUnit;
  
  function selectUnit() {}
  </code></pre>
  
  <p>But I could not make it work with parameters :</p>
  
  <pre><code>function appendUnit(nb) {
      var newDiv = document.createElement("div");
  
      newDiv.id = "unit" + nb;
      newDiv.onclick = selectUnit(this.id); // This throws me undefined
      document.getElementById("unitsList").appendChild(newDiv);
  }
  
  function selectUnit(id) {
      console.debug(id);
  }
  </code></pre>
  
  <p>How can I do that ?</p>