title: onclick function not working into .append?
body: <p>I try to create the <code>div</code> tag using javascript and jquery. And i try onclick function apply to the <code>div</code> tag but this is not working? </p>
  
  <pre><code>var header = '&lt;div id = "header" style="height:150px; width:500px; background:#a2a2a2;" &gt;&lt;/div&gt;';
  document.body.insertAdjacentHTML('beforeend',header);
  $("#header").append('&lt;div id="con" style="height:20%; width:30%; background:orange;" onclick="alert('hello world')"&gt;&lt;/div&gt;');
  </code></pre>
  
  <p>IN the code i used onclick function inside the <code>div id="con"</code> tag not worked.? but Instead of i used </p>
  
  <pre><code>$("#header").append('&lt;div id="con" style="height:20%; width:30%;  background:orange;" onclick="mufunc();"&gt;&lt;/div&gt;');
  function mufunc(){
  alert("hello world");
  }
  </code></pre>
  
  <p>In this code onclick function is working. </p>
  
  <p>I need to alert the code inside the <code>&lt;div&gt;</code> How can i do it? What is the difference between the both function?</p>