开发者

jQuery Datepicker changes date to today

开发者 https://www.devze.com 2022-12-24 07:58 出处:网络
I\'m using jQuery Datepicker but I\'m having trouble when editing records. // js code $(function(){ $(\".datepicker\").datepicker().datepicker(\'option\', \'dateFormat\', \'yy-mm-dd\').datepicker(\'o

I'm using jQuery Datepicker but I'm having trouble when editing records.

// js code
$(function(){
    $(".datepicker").datepicker().datepicker('option', 'dateFormat', 'yy-mm-dd').datepicker('option', 'changeMonth', 'true').datepicker('option', 'changeYear', 'true');
})

// the input
<input type="text" name="valid_from" val开发者_JAVA百科ue="2010-02-27" class="datepicker" />

But when the page is rendered the date shown (and selected when I open the datepicker) is of today.

I'm can't really understand what's going on.


you should also change your code to put all the options in one call like this

  $(".datepicker").datepicker({dateFormat:'yy-mm-dd',changeMonth:true,changeYear:true});


remove the option:

.datepicker( "option", "gotoCurrent", true );

this moves your date to the current date: gotoCurrent

0

精彩评论

暂无评论...
验证码 换一张
取 消