title: Input number's value to append div's
body: <p>Fiddle - <a href="http://liveweave.com/enRy3c" rel="nofollow noreferrer">http://liveweave.com/enRy3c</a></p>
  <p>Here's what I'm trying to do.</p>
  <p>Say my input number is 5. I want to dynamically append 5 divs to the class <code>.enfants</code>. However I haven't figured out how to do that. I been searching and searching and I haven't came across anything.</p>
  <p><strong>jQuery/JavaScript</strong>:</p>
  <pre><code>var counter = 1;
  
  // Value number = .enfants children
  $(&quot;.ajouter-enfants&quot;).on('keyup change', function() {
    var yourChildren = &quot;&lt;div&gt;&quot; + counter++ + &quot;&lt;/div&gt;&quot;;
    var CallAppend = function() {
      $(&quot;.enfants&quot;).append( yourChildren );
    };
    
    // If 0 or empty clear container
    if ( $.inArray($(this).val(), [&quot;0&quot;, &quot;&quot;, &quot; &quot;]) &gt; -1 ) {
      $(&quot;.enfants&quot;).html(&quot;&quot;);
      // If only add/have 1 div in container
    } else if ($(this).val() === &quot;1&quot;) {
      $(&quot;.enfants&quot;).html(&quot;&quot;).append( yourChildren );
      // If &gt; 0 add as many divs as value says
    } else {
      $(&quot;.enfants&quot;).html(&quot;&quot;);
      CallAppend();
    }
  });
  </code></pre>
  <p><strong>HTML</strong>:</p>
  <pre><code>&lt;div class=&quot;contenu&quot; align=&quot;center&quot;&gt;
    &lt;div&gt;
      Value number = .enfants children
    &lt;/div&gt;
    &lt;input type=&quot;number&quot; min=&quot;0&quot; class=&quot;ajouter-enfants&quot; value=&quot;0&quot; /&gt;
    &lt;div class=&quot;enfants&quot;&gt;
  
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>