title: Adding a multiple buttons in 1 click
body: <p>I am trying to create a click event within a function, which doesn’t seem to work.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>&lt;input class="text2" type="text" name="" id="text1"&gt;
  &lt;input size="20" id="high_light" type="button" /&gt; 
  &lt;span&gt;&lt;a href="#" id="add"&gt; + Add more&lt;/a&gt;&lt;/span&gt;
  
  
  var count = $('.text2').val();
  var divCount = count;
  
  window.onload = function(){
     document.getElementById("add").onclick = function(){
        if(divCount &lt; count){
           divCount++;
  
           var input = document.getElementById("high_light" + divCount);
           input.parentNode.style.display = "";
        }
     };
  }
  </code></pre>
  
  <p>Basically, I just want to add more buttons with 1 click. The text2 <code>class</code> in where I will enter the value of how many buttons I want to add. When I change the value of divCount to 1 (divCount = 1), it is working but it is just a fixed adding of button. I am new to this so i apologize if my code in not that organized.</p>
  
  <p>This code is working, but it is only adding buttons 1 by 1 with a max of 4.</p>
  
  <pre><code>window.onload = function(){
      document.getElementById("add").onclick = function(){
  
          if(divCount &lt; 4)
          {
              divCount++;
  
              var input = document.getElementById("high_light" + divCount);
              input.parentNode.style.display = "";
  
          }
  
      };
  }
  </code></pre>