title: javascript append onclick func is not defined
body: <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function ABC(obj) {
    $("#ID").append('&lt;div onclick="obj.func();"&gt;TEST&lt;/div&gt;');
  }
  
  ABC({func: function() { alert("abc"); } })</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;div id="ID"&gt;&lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>If you run this function, you will not be able to run obj.func</p>
  
  <p><p>Why is it not called defined?
  <p>How can I solve it?</p>