我有用户选择日期的代码。如何从datepicker ui获取年份?
我需要获得价值年,并把它放在div。
我该怎么做?
许多THX。 代码:
<div class="demo">
<p>Date: <input type="text" id="datepicker"></p>
</div>
<div id="Year"></div>
$("#datepicker").datepicker({
changeMonth: true,
changeYear: true
});
$("#Year").text($("#datepicker").val());
我尝试使用.substring(0, 4)
但我不硝酸钾如何。
您的权利,下seloution正确但如何显示它没有按div – yossi
中的按钮添加活动的现场示例,请阅读洞的答案,这样你就会知道从哪里获得帮助下一次你需要这样的事情:) – balexandre
我想指出你out datepicker和timepicker,我喜欢使用,因为它们与[** Bootstrap Framework **](http://twitter.g ithub.com/bootstrap/scaffolding.html)(最常用的CSS框架之一),[** DatePicker **](http://www.eyecon。ro/bootstrap-datepicker /)和[** TimePicker **](http://jdewit.github.com/bootstrap-timepicker/)。 – balexandre