title: Function to add div (switch between functions)
body: <p>Hoping someone can help me. I'm trying to create a function which adds a <code>div</code> (not the problem).</p>
  
  <p>The problem is that I want the function to check if the <code>div</code> before is <code>div1</code> or <code>div2</code>, and then add the next.</p>
  
  <p>The pattern should look like this: div1, div2, div1, div2 etc. Right now I have 2 buttons, where the adds div1 and the other adds div2. I need a button, which adds 1 div onClick, but checks which div has already been added and then adds the next div(div1 or div2) inline.</p>
  
  <p>My code so far:</p>
  
  <pre><code>function div1(){
                      var div1 = document.createElement("div");
  
                      div1.className = "div1";
  
                      $('.wrapper').append(div1);
                  }
  
                  function div2(){
                      var div2 = document.createElement("div");
                      div2.className = "div2";
  
                      $('.wrapper').append(div2);
  
                  }
  
                  $(".addDiv1").click(function(){
                      div1();
                  })
                  $(".addDiv2").click(function(){
                      div2();
                  })
  </code></pre>