2015-01-01 20 views

回答

2

可以使用defaultDate设置默认的月份。 http://jqueryui.com/datepicker/

$(function() { 
var d = new Date(); 
d.setMonth(1); //Defalt month feburary 
$("#datepicker").datepicker({ 
     defaultDate: d 
    }); 
}); 

Demo

+0

真棒,谢谢。我在想应该有一个setMonth和setYear方法。但没有意识到。 :) http://jsfiddle.net/Superman/tx32r7y7/ – Superman

+1

欢迎。很高兴帮助你。 – Sadikhasan

1

这里u能看到的只有一个月JQuery的日期选择器:

以下代码:

<html> 
<head> 
<meta charset="utf-8"> 
<title>jQuery UI Datepicker - Default functionality</title> 
    <link rel="stylesheet" href="http://code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css"> 
    <script src="http://code.jquery.com/jquery-1.10.2.js"></script> 
    <script src="http://code.jquery.com/ui/1.11.2/jquery-ui.js"></script> 
    <link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css"> 
<script> 
$(function() { 
    $("#datepicker").datepicker(); 
}); 
</script> 
</head> 
    <body> 
    <p>Date: <input type="text" id="datepicker"></p> 
    </body> 
</html> 

在这里展示不同的选择:

http://api.jqueryui.com/datepicker/

+0

默认情况下可以看到2月吗?而在另一个例子中,我只想看到八月。 – Superman

+0

是的,你可以设置... – ketan

相关问题