If I want to display the JQUERY UI datepicker inline by attaching it to a DIV like $(\"div#someID\").datepicker()
- how do I access the chosen date? I assume if
You can use the getDate
method:
var d = $('div#someID').datepicker('getDate');
That will give you a Date object in d
.
There aren't any options for positioning the popup but you might be able to do something with CSS or the beforeShow
event if necessary.
If your selected elements are not one, you need use this way:
$('[type="date"]').datepicker();
$('[type="date"]').change(function() {
var date = $(this).datepicker("getDate");
console.log(date);
});
If you want to get the date when the user selects it, you can do this:
$("#datepicker").datepicker({
onSelect: function() {
var dateObject = $(this).datepicker('getDate');
}
});
I am not sure about the second part of your question. But, have you tried using style sheets and relative positioning?
To position the datepicker next to the input field you could use following code.
$('#datepicker').datepicker({
beforeShow: function(input, inst)
{
inst.dpDiv.css({marginLeft: input.offsetWidth + 'px'});
}
});