嗨,这是我的日期选择器
HTML:
<div class="field-birthday field-return" id="birthday-edit" style="display:none;">
<div class="birthdaypicker"></div>
<input class="hidden" name="birthday" type="hidden" id="birthday" >
这是在.js:
$('.birthdaypicker').datepicker({
dateFormat: 'dd MM'
}).on("change", function(){
var date = $('input[name="birthday"]').val($(this).val());
console.log(date);
}).datepicker('setDate', "-30y");
我是jQuery的新手,js,...我很失落,我需要获得所选日期的价值,但我找不到任何明确的例子来说明这一点!需要帮助!谢谢!
答案 0 :(得分:2)
将您的代码更改为:
$('.birthdaypicker').datepicker({
dateFormat: 'dd MM'
}).on("change", function(){
$('input[name="birthday"]').val($(this).val()); // remove var date and set date here
console.log($('input[name="birthday"]').val()); // directly get date here
}).datepicker('setDate', "-30y");