最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Reset date in datetimepicker - Stack Overflow

programmeradmin2浏览0评论

Using bootstrap datetimepicker. Submitting the form via ajax and need to reset date based on ajax response. But currently facing an issue to reset the date selection from JQuery. Here is the code I used to reset:

$("#date_from").datetimepicker("setDate", null);

Using bootstrap datetimepicker. Submitting the form via ajax and need to reset date based on ajax response. But currently facing an issue to reset the date selection from JQuery. Here is the code I used to reset:

$("#date_from").datetimepicker("setDate", null);
Share Improve this question asked Mar 17, 2016 at 7:04 Web_DeveloperWeb_Developer 1,2513 gold badges20 silver badges34 bronze badges 1
  • Which version you are using?? – Moumit Commented Mar 17, 2016 at 7:19
Add a ment  | 

5 Answers 5

Reset to default 3

Can you try this.

$('#date_from').val("");
$('#date_from').datetimepicker('update');

Refered from methods tab of datepicker

Try this code:

    $('#date_from').data("DateTimePicker").clear();

reference here: https://eonasdan.github.io/bootstrap-datetimepicker/Functions/#clear

@Jayaraj.K's answer did not work for me.
This is what I used:

$('#date_from').data('DateTimePicker').date(null)
$('#date_from').datetimepicker('update');
$("#date_from").datepicker().datepicker("setDate", new Date());

Try this code:

$.datepicker._clearDate(this);
发布评论

评论列表(0)

  1. 暂无评论