title: Adding click event for a button created dynamically using jQuery
body: <p>How to add a button click event on a button that was added dynamically using jQuery?</p>
  
  <p>The jQuery code that adds the dynamic buttons inside a <code>div</code> container:</p>
  
  <pre><code>$('#pg_menu_content').empty();
  $div = $('&lt;div data-role="fieldcontain"/&gt;');
  $("&lt;input type='button' value='Dynamic Button' id='btn_a' /&gt;").appendTo($div.clone()).appendTo('#pg_menu_content');
  </code></pre>
  
  <p><strong>Question 1:</strong>
  How can I add a click event for the above button?  I tried the below and it has not triggered</p>
  
  <pre><code>$("#btn_a").click(function(){
    alert ('button clicked');
  });
  </code></pre>
  
  <p><strong>Question 2:</strong>
  How can I get the value of the button inside the click event?  For example I want to get the value 'Dynamic Button' inside the click event function.</p>
  
  <p>Can you guys please help me on this.</p>