[英]Twitter's bootstrap datetime picker
Hi I am using the following plugin to show datetime in my input fields the problem is that i can't get the value and can't understand how to do it. 嗨我使用以下插件在我的输入字段中显示日期时间问题是我无法获得值,无法理解如何做到这一点。 The plugin .
插件 。 I can't understand what is the function but for sure this is not working:
我无法理解功能是什么,但肯定这不起作用:
HTML: HTML:
<div class="input-append date datetimepicker" data-date="12-12-2012"
data-date-format="dd-mm-yyyy">
<input class="span2" size="16" type="text" value="12-12-2012">
<span class="add-on"><i class="icon-th"></i></span>
</div>
<div id="view"></div>
JS: JS:
$(document).ready(function() {
$('.datetimepicker').datetimepicker({
format: 'dd-mm-yyyy hh:ii',
todayBtn: true,
pickerPosition: "bottom-left"
});
});
$(document.body).on('change', ".datetimepicker", function(e){
var date = $(".datetimepicker").getDate();
$("#view").html(date);
});
I get the error 我收到了错误
Object [object Object] has no method 'getDate'
Object [object Object]没有方法'getDate'
So clearly I have some error but can't find it and in documentation I can't find how to extract the date from the field. 很明显我有一些错误,但找不到它,在文档中我找不到如何从字段中提取日期。 Please help!
请帮忙!
$('.datetimepicker').datetimepicker().on('changeDate', function(ev){
console.log(ev.date.valueOf());
});
or 要么
$(document.body).on('change', ".datetimepicker", function(e){
var date = e.date.valueOf();
$("#view").html(date);
});
$(document.body).on('changeDate', ".datetimepicker", function(e){
var date = e.date.valueOf();
$("#view").html(date);
});
$(document).ready(function() {
$('.datetimepicker')
.datetimepicker({
format: 'dd-mm-yyyy hh:ii',
todayBtn: true,
pickerPosition: "bottom-left"
})
.on('changeDate', function(ev){
$("#view").html(ev.date.valueOf());
});
}); });
OK, I've done this is the code I needed thanks to @acudars and @rps 好的,我已经完成了这是我需要的代码感谢@acudars和@rps
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.