【发布时间】:2019-03-19 10:20:39
【问题描述】:
我需要在日历关闭后获取我的input 中显示的值。
以下是我尝试过但从未遇到过任何一个的代码
$('#startDate').click(function () {
console.log('1: ' + $('#startDate').val())
})
$('#startDate').change(function () {
console.log('1.25: ' + $('#startDate').val())
})
$('#startDate').on("change", function() {
alert($(this).val());
});
$('#startDate').on("change paste keyup", function() {
alert($(this).val());
});
$("#startDate").on("input propertychange",function(){
alert($(this).val());
});
$("#startDate").on("change paste keyup select", function() {
alert($(this).val());
});
$("#startDate").bind('change', function(event) {
alert( $("#startDate").attr("value") );
});
这是我的 HTML
<div class="col-md-3 col-lg-2 col-sm-12 col-xs-12">
<label for="startDate">Start date (MM/YYYY)</label>
<div class="input-group datetime" id="start_picker"
data-date-format="MM/YYYY">
<input type="text" name="startDate" id="startDate"
class="form-control make-datepicker" data-date-format="MM/YYYY"
data-parsley-date="" maxlength="7" autocomplete="off">
<span class="input-group-addon">
<span class="fa fa-calendar"></span>
</span>
</div>
我还在 input 元素 (<input id="startDate" onchange="test()">) 上尝试了 onchange,它应该在我的 JQuery 中调用函数调用,但仍然没有。
我需要这个值,所以我可以过滤一个表,但我现在很难过。
当我第一次在字段中单击以显示日历时,此行确实有效
$('#startDate').click(function () {
console.log('1: ' + $('#startDate').val())
})
【问题讨论】:
标签: jquery html bootstrap-datepicker bootstrap-datetimepicker