title: How to find the next and previous months with JavaScript?
body: <p>My jQuery function takes in the <code>current month</code>. I would like to display the next and previous months depending on the buttons clicked.</p>
  
  <p>My question is, is there a <code>default</code> <code>Date()</code> function I can call to know the next and previous months of a current month ?</p>
  
  <pre><code>$(document).ready(function () {
      var current_date = $('#cal-current-month').html();
      //current_date will have September 2013
      $('#previous-month').onclick(function(){
          // Do something to get the previous month
      });
      $('#next-month').onclick(function(){
          // Do something to get the previous month
      });
  });
  </code></pre>
  
  <p>I can write some code and get the next and previous months, but I was wondering if there is any already <code>defined functions</code> for this purpose?</p>
  
  <p><strong>SOLVED</strong></p>
  
  <pre><code>var current_date = $('.now').html();
  var now = new Date(current_date);
  
  var months = new Array( "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
  
  $('#previous-month').click(function(){
      var past = now.setMonth(now.getMonth() -1);
      $('.now').html(months[now.getMonth()]+' '+now.getFullYear());
  });
  
  $('#next-month').click(function(){
      var future = now.setMonth(now.getMonth() +1);
      $('.now').html(months[now.getMonth()]+' '+now.getFullYear());
  });
  </code></pre>