bootstrap 日期选择器:运行 更改日期时的功能
bootstrap datepicker: run function when date is changed
我想在用户使用日期选择器更改日期输入值时运行一个函数,这是我的代码:
html:
<div class="input-group date form-group" data-provide="datepicker">
<input type="text" class="form-control" id="birthdate"
name="birthdate" placeholder="Student Birth Date...">
<div class="input-group-addon">
<span class="glyphicon glyphicon-th"></span>
</div>
</div>
js:
$('#birthdate').datepicker({
format: 'yyyy/mm/dd',
startDate: '-3d'
});
$('#birthdate').datepicker()
.on('changeDate', function(e) {
alert();
});
更改日期后,没有任何反应。我在问这个问题之前搜索过这个问题,但没有答案解决我的问题!
试试 'change event'
演示:http://jsfiddle.net/Z3CRA/99/
$('#birthdate').datepicker({
format: 'yyyy/mm/dd',
startDate: '-3d'
});
$( "#birthdate" ).change(function() {
alert( "Handler for .change() called." );
});
更新:你应该 select div#datepicker 不要直接输入。
演示:http://jsfiddle.net/8ac7b7Lh/4/
$('#datepicker').datepicker({
format: 'yyyy/mm/dd',
startDate: '-3d'
});
$('#datepicker').datepicker().on('changeDate', function (ev) {
console.log('Input changed');
});
我想在用户使用日期选择器更改日期输入值时运行一个函数,这是我的代码:
html:
<div class="input-group date form-group" data-provide="datepicker">
<input type="text" class="form-control" id="birthdate"
name="birthdate" placeholder="Student Birth Date...">
<div class="input-group-addon">
<span class="glyphicon glyphicon-th"></span>
</div>
</div>
js:
$('#birthdate').datepicker({
format: 'yyyy/mm/dd',
startDate: '-3d'
});
$('#birthdate').datepicker()
.on('changeDate', function(e) {
alert();
});
更改日期后,没有任何反应。我在问这个问题之前搜索过这个问题,但没有答案解决我的问题!
试试 'change event'
演示:http://jsfiddle.net/Z3CRA/99/
$('#birthdate').datepicker({
format: 'yyyy/mm/dd',
startDate: '-3d'
});
$( "#birthdate" ).change(function() {
alert( "Handler for .change() called." );
});
更新:你应该 select div#datepicker 不要直接输入。
演示:http://jsfiddle.net/8ac7b7Lh/4/
$('#datepicker').datepicker({
format: 'yyyy/mm/dd',
startDate: '-3d'
});
$('#datepicker').datepicker().on('changeDate', function (ev) {
console.log('Input changed');
});