2016-11-02 65 views
0

我使用jquery jquery-1.9.1.min.js。我有以下的JSP与一个datepickerJQuery datepicker显示月份下拉列表change月份

<script type="text/javascript"> 

     $(function() { 
      $("#datepicker1").datepicker({ 
       changeMonth: true, 
       changeYear: true, 
       defaultDate: new Date('2016','11','02'), 
      setDate: new Date('2016','11','02') 
      }); 
      }); 

</script> 
</head> 
<body> 
    <%@include file="../menu/cabeceraMenu.jsp"%> 
    <%@include file="../menu/opcionesEncuesta.jsp"%> 
    <form action="${pageContext.request.contextPath}/encuesta/nueva" 
     name="frm" id="nueva-encuesta" method="post" style="margin: 0px;"> 
     <table class="tablaCentral"> 
      <tr> 
     <td> 
     Date: <input type="text" id="datepicker1"> 
     </td> 
     </tr> 
     </table> 

</body> 
</html> 

这是输出屏幕

enter image description here

我怎样才能在屏幕dropdrown框显示月份名称和编号的一年。现在他们是空的。

日期是 新的日期( '2016', '11', '02')去除defaultDatesetDate后 我想与11月成立箱和2016年

+0

你使用的jQuery UI的版本?和主题? – Aroniaina

+0

jquery-1.9.1.min.js –

+0

只有jquery没有datepicker,你必须使用jQuery UI和主题,如果你想! (就像你回答@CharantejGolla) – Aroniaina

回答

1

尝试。

$(function() { 
 
    $("#datepicker1").datepicker({ 
 
     changeMonth: true, 
 
     changeYear: true 
 
    }); 
 
    });
<link href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" rel="stylesheet"/> 
 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> 
 
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> 
 
<input type="text" id="datepicker1">

+0

我删除了changeMonth和changeYear,但我没有看到月份名称和年份。我使用Firefox。我检查了你的脚本,现在它工作。非常感谢 – user3712581

相关问题