jQuery の日付ピッカーを使用して、アプリ全体にカレンダーを表示しています。カレンダーではなく、月と年 (2010 年 5 月) を表示できるかどうか知りたいです。
ベストアンサー1
ここにハックがあります(.html ファイル全体を更新しました):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js"></script>
<link rel="stylesheet" type="text/css" media="screen" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/base/jquery-ui.css">
<script type="text/javascript">
$(function() {
$('.date-picker').datepicker( {
changeMonth: true,
changeYear: true,
showButtonPanel: true,
dateFormat: 'MM yy',
onClose: function(dateText, inst) {
$(this).datepicker('setDate', new Date(inst.selectedYear, inst.selectedMonth, 1));
}
});
});
</script>
<style>
.ui-datepicker-calendar {
display: none;
}
</style>
</head>
<body>
<label for="startDate">Date :</label>
<input name="startDate" id="startDate" class="date-picker" />
</body>
</html>
上記の例の jsfiddleを編集します。http://jsfiddle.net/DBpJe/7755/
編集 2完了ボタンをクリックした場合にのみ、入力ボックスに月年の値を追加します。また、入力ボックスの値を削除することもできますが、これは上記のフィールドでは不可能です。http://jsfiddle.net/DBpJe/5103/
編集 3 rexwolf のソリューションに基づいて、より良いソリューションを更新しました。
http://jsfiddle.net/DBpJe/5106