0

I have a very simple setup which is surprisingly not working:

HTML

<input type="text" value="08/03/2016" class="datepicker" />

JS

$(document).ready(function() {
   $('.datepicker').datepicker({
       setDate: "08/03/2016"
   });
});

No matter if having input-value set or not, its always showing up October 2015 on open. Why so?

2
  • 1
    Which Datepicker library are you using ? Have you try a different date format, like 2016-03-08 ? Commented Oct 30, 2015 at 13:26
  • 2
    Can you create a sample on JSFiddle? Commented Oct 30, 2015 at 13:34

2 Answers 2

2

Try this:

$( ".datepicker" ).datepicker( "setDate", "08/03/2016" );

Its a method call and not the option while initializing it.

Sign up to request clarification or add additional context in comments.

Comments

1

You have to initialize the datepicker first:

$(function() {
    $('.datepicker').datepicker();
    $('.datepicker').datepicker("setDate",  "08/03/2016");
});

https://jsfiddle.net/n3Lapbhn/2/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.