【发布时间】:2015-07-30 08:48:04
【问题描述】:
我希望月份和年份与这个月/年选择器分开。我试过了。
我想在数据库中插入月份和年份,为此我希望它分开。我正在使用 codeigniter 框架
var month= $("#ui-datepicker-div .ui-datepicker-month :selected").val();
window.write(' month');
它不工作。
<!--<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">-->
<script src="../monthyear/jquery-ui.js"></script>
<link rel="stylesheet" href="jquery-ui.css">
<label for="monthYearPicker">Date :</label>
<div class="monthYearPicker" name="myDate" ></div>
<!--<input name="myDate" class="monthYearPicker" />-->
<script>
$(document).ready(function () {
$(function () {
$('.monthYearPicker').datepicker({
changeMonth: true,
changeYear: true,
showButtonPanel: true,
dateFormat: 'MM yy'
}).focus(function () {
var thisCalendar = $(this);
$('.ui-datepicker-calendar').detach();
$('.ui-datepicker-close').click(function () {
var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
thisCalendar.datepicker('setDate', new Date(year, month, 1));
});
});
});
});
</script>
<style>
.ui-datepicker-calendar {
visibility:hidden;
}</style>
【问题讨论】:
-
“它不工作”是什么意思?
-
先生,我将如何通过邮寄方式获得月份?
-
用您面临的实际问题更新您的问题
-
例如:如果它的显示(pageonload)JULY/2015,我想要 2015 年 7 月和 2015 年的月份;
-
检查这个:[类似的日期选择器问题][1] [1]:stackoverflow.com/questions/16186386/…
标签: javascript jquery