开发者

jQuery Datepicker changes date to today

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜