1
我想知道爲什麼我無法獲取我的隱藏輸入值(日期選擇器引導內聯) 將內置日期選擇器內聯爲doc,所以我必須添加隱藏輸入並在此之後獲得他對變化的價值。獲取隱藏輸入的更改值
的HTML代碼:
<div id="datepicker" class="input-group date" data-date-format="dd-mm-yyyy"></div>
<input type="hidden" id="my_hidden_input" class="form-control">
的JS代碼:
jQuery('#datepicker').datepicker();
jQuery('#datepicker').on('changeDate', function() {
jQuery('#my_hidden_input').val(
jQuery('#datepicker').datepicker('getFormattedDate')
);
});
jQuery(document).ready(function() {
jQuery("#datepicker").datepicker({
startDate: new Date(),
language: "fr",
autoOpen:true,
autoclose: true,
todayHighlight: true
//datesDisabled: ['22/02/2017', '28/02/2017']
}).datepicker('update', new Date());;
});
jQuery("#datepicker .form-control").val().trigger('change', function() {
alert(jQuery(this).val()); //here
});
jQuery('#datepicker').datepicker();
jQuery('#datepicker').on('changeDate', function() {
jQuery('#my_hidden_input').val(
jQuery('#datepicker').datepicker('getFormattedDate')
);
});
jQuery(document).ready(function() {
jQuery("#datepicker").datepicker({
startDate: new Date(),
language: "fr",
autoOpen:true,
autoclose: true,
todayHighlight: true
}).datepicker('update', new Date());;
});
jQuery("#datepicker .form-control").change(function() {
alert(jQuery(this).val());
});
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/css/bootstrap-datepicker3.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/locales/bootstrap-datepicker.fr.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/js/bootstrap-datepicker.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<div id="datepicker" class="input-group date" data-date-format="dd-mm-yyyy"></div>
<input type="hidden" id="my_hidden_input" class="form-control">
創建。所以,一個小提琴鏈接我們可以檢查 –