我在从bootstrap-timepicker24表单获取文本值时遇到困难。
jsp代码:
<form action="#" class="form-horizontal form-bordered" id="shop-time">
<div class="form-body form" >
<div class="form-group">
<label class="control-label col-md-4">Monday</label>
<div class="col-md-4">
<div class="input-group shop-monday-open-time">
<input type="text" class="form-control timepicker timepicker-24">
<span class="input-group-btn">
<button class="btn default" type="button">
<i class="fa fa-clock-o"></i>
</button>
</span>
</div>
</div>
</div>
js代码:
// forms
var shopForm = $('#shop-time');
var shopMondayOpen = shopSave.find('.shop-monday-open-time');
// time picker listener
shopMondayOpen.on('changeTime.timepicker', function(open) {
var time = dateInUTC(open.time);
});
但是事件
changeTime
不会影响侦听器。但是,如果我只是重新加载页面并在以下行的断点处停止:var shopMondayOpen = shopSave.find('.shop-monday-open-time')
行并在控制台上评估shopMondayOpen.val
,我会得到类似以下内容:shopMondayOpen.val
jquery.min.js:4 function (a){var b,c,d,e=this[0];{if(arguments.length)return d=m.isFunction(a),this.each(function(c){var e;1===this.nodeType&&(e=d?a.call(this,c,m(this).val()):a,null==e?e="":"number"==typeof e?e+="":m.isArray(e)&&(e=m.map(e,function(a){return null==a?"":a+""})),b=m.valHooks[this.type]||m.valHooks[this.nodeName.toLowerCase()],b&&"set"in b&&void 0!==b.set(this,e,"value")||(this.value=e))});if(e)return b=m.valHooks[e.type]||m.valHooks[e.nodeName.toLowerCase()],b&&"get"in b&&void 0!==(c=b.get(e,"value"))?c:(c=e.value,"string"==typeof c?c.replace(lc,""):null==c?"":c)}}
我尝试使用timepicker-24 manual,但并没有使我走得太远。
猜猜我丢失了一些东西,但是我无法弄清楚。
最佳答案
几天后,我得出了一个结论,那就是从timepicker-24中获得价值的唯一途径就是从管制员那里获得价值,正如我在评论我的帖子时所说的那样:
<input type="text" class="form-control timepicker timepicker-24 shop-monday-open">
var time = $('shop-monday-open').val
关于javascript - 从bootstrap-timepicker24获取值(value),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/29734248/