当您输入 时,我的.auto-input
函数会填充容器 div ,但是当您选择日期时,它不会获取字段中的值并填充div 文本。.text
input
flatpickr input
.flatpickr
如何.flatpickr
根据来自的输入来填充其中的文本#flapickr
?
$('.auto-input').keyup(function() {
var $this = $(this);
$('.' + $this.attr('id') + '').html($this.val());
});
var example = flatpickr("#flatpickr", {
locale: "en",
altInput: true,
dateFormat: "d-m-Y",
minDate: "1950-01-01",
allowInput: false
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="input-wrapper">
<input class="auto-input" id="text" type="text" /><br/>
<input class="auto-input" id="flatpickr" type="text" placeholder="deal expires on...">
</div>
<div class="input-fill-holder">
<div class="text"></div>
<div class="flatpickr">Fill Date Here</div>
</div>
<link href="https://npmcdn.com/flatpickr/dist/flatpickr.css" rel="stylesheet" type="text/css">
<link href="https://npmcdn.com/flatpickr/dist/themes/airbnb.css" rel="stylesheet" type="text/css">
<script src="https://npmcdn.com/flatpickr/dist/flatpickr.min.js"></script>
<script src="https://npmcdn.com/flatpickr/dist/l10n/fr.js"></script>