title: Anonymous function error : SyntaxError: Unexpected end of input
body: <p>I'm dynamically creating DOM elements in my Javascript code, and I am trying to add an anonymous function as an <code>onclick</code> event handler. Here is my code :</p>
  
  <pre><code>var onClickFunction = "(function(){var x = document.getElementById('onPrsClickButton'); x.value = this.id; x.click();})()";
  
  var libelle = '&lt;div onclick=' + onClickFunction + '&gt;&lt;/div&gt;'
  </code></pre>
  
  <p>But whenever I click this <code>&lt;div&gt;</code>, the console gives me this error : </p>
  
  <pre><code>SyntaxError: Unexpected end of input
  </code></pre>
  
  <p>Does anyone know why ? Thanks !</p>