title: Adding div dynamically using button click in JavaScript / jQuery
body: <p>How do I dynamically add div on button click in JavaScript/jQuery? 
  I want all the formatting of div having class "listing listing_ad job".</p>
  
  <p>This is my code which I tried out, using jQuery. </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$('#btnAddtoList').click(function(){
   var newDiv = $('&lt;div class="listing listing_ad job"&gt;&lt;h4&gt;&lt;a&gt;Some text&lt;/a&gt;&lt;/h4&gt; &lt;/div&gt;');
    //newDiv.style.background = "#000";
    document.body.appendChild(newDiv);
  });</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.listing {
    border-bottom: 1px solid #ddd;
    float: left;
    padding: 0 0 5px;
    position: relative;
    width: 559px;
  }
  
  .listing:hover {
    background: #f5f5f5 none repeat scroll 0 0;
    border-bottom: 1px solid #ddd;
    cursor: wait;
  }
  
  a:hover {
    color: #ff5050;
  }
  
  .subtitle {
    width: 430px;
    font-weight: normal;
    font-size: 12px;
    font-family: Arial;
    color: #7f7f7f;
  }
  
  .info {
    float: left;
    margin: 10px 15px 5px;
    min-width: 500px;
    
    clear: both;
    color: #7f7f7f;
    margin: 15px 44px 15px 0;
    overflow: hidden;
  }</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;button id="btnAddtoList"&gt;
  Add to list
  &lt;/button&gt;
  
  &lt;div class="listing listing_ad job"&gt;
    &lt;h4&gt;
     &lt;a&gt;
    Excellent Opportunity For Internship at Diamond
    &lt;/a&gt;
    &lt;/h4&gt;
    &lt;div class="subtitle"&gt;
    Lahore, Punjab
    &lt;/div&gt;
    &lt;div class="info"&gt;
    This is Info / Description.
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;!-- ************************ --&gt;
  
  &lt;div class="listing listing_ad job"&gt;
    &lt;h4&gt;
    &lt;!-- Src: http://jobs.mitula.pk/internship-program-lahore-jobs --&gt;
    &lt;a&gt;
    Excellent Opportunity For Internship at Diamond
    &lt;/a&gt;
    &lt;/h4&gt;
    &lt;div class="subtitle"&gt;
    Lahore, Punjab
    &lt;/div&gt;
    &lt;div class="info"&gt;
    This is Info / Description.
    &lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  
  Jsfiddle: <a href="http://jsfiddle.net/mr4rngbL/3/" rel="nofollow">http://jsfiddle.net/mr4rngbL/3/</a></p>