Abhishek Honrao
Abhishek Honrao

Reputation: 835

Display a datepicker

How can i display a datepicker in a div on document.ready() without onclick of input tag?

<div id="return_datepicker"></div>

my js -

$("#return_datepicker").datepicker();
$("#return_datepicker").datepicker("setDate", new Date());
$("#return_datepicker").datepicker('show');

Upvotes: 0

Views: 55

Answers (1)

Praveen Poonia
Praveen Poonia

Reputation: 765

You need to call the initialization of datepicker in IIFE. Try below code -

$(function() {
    $("#return_datepicker").datepicker();
    $("#return_datepicker").datepicker("setDate", new Date());
    $("#return_datepicker").datepicker('show');
  });

For more detail see JQuery UI docs

Upvotes: 1

Related Questions