Always visible jQuery UI DatePicker

Piotr G picture Piotr G · Nov 15, 2010 · Viewed 35.2k times · Source

How can I use jQuery UI to display an always-visible datepicker widget?

Answer

Cᴏʀʏ picture Cᴏʀʏ · Nov 15, 2010

It's simple. Keep your jQuery code, but assign it to a <div> instead of an input box.

Date:
<div id="datepicker"></div>

<script>
    $(function() {
        $("#datepicker").datepicker();
    });
</script>

A functional example lives at the jQuery UI webpage for the datepicker widget, and I've also included one below.

$(function() {
  $("#datepicker").datepicker();
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>

<div id="datepicker"></div>