title: jQuery Datepicker onClose select next
body: <p>I have a system where people can add multiple from and to dates ie screenshot: <img src="https://i.stack.imgur.com/6v9Q8.png" alt="http://screencast.com/t/Q7MHQVLnn4J9"></p>
  
  <p>On selecting the first date the onClose event sets the date for second input and opens it. IE</p>
  
  <pre><code>datePickers = function() {
      $(".from_date").datepicker({
        minDate: 'D',
        dateFormat: "dd/mm/yy",
        defaultDate: "+1w",
        numberOfMonths: 2,
        onClose: function(selectedDate) {
          $(".to_date").datepicker("option", "minDate", selectedDate);
          return $(".to_date").datepicker("show");
        }
      });
      return $(".to_date").datepicker({
        minDate: '+1D',
        dateFormat: "dd/mm/yy",
        defaultDate: "+1w",
        numberOfMonths: 2
      });
    };
  </code></pre>
  
  <p>My problem becomes when I have 2,3 or more and editing the first or second one.... On close it opens the last input.</p>
  
  <p>I have tried using .next('to_date') and closest('to_date') but its not working.</p>
  
  <p>Any advise on how I can get around this.</p>
  
  <p>As requested a fiddle:  <a href="http://jsfiddle.net/FdfPY/" rel="noreferrer">http://jsfiddle.net/FdfPY/</a></p>