onblur 取最后点击的值不取当前点击的值?

onblur taking last clicked value not taking current clicked value?

我正在使用 onblur 事件来获取日期选择器中的日期值。这是我的控件:

<input placeholder="MM/DAY/YEAR" data-bind="value: CustomerBookingTbl.PickUpDate" class="input date" name="pickupdate" onblur="UpdatePrice(this)" type="text" required>

这是我的功能:

function UpdatePrice(_this)
{
    console.log(_this.value);
}

当我点击 06/07/2017 时,它为 null。之后,我点击了 06/07/2017 然后它将 06/06/2017 作为值。

我也附上图片

查看 datePicker

提供的活动

Datepicker triggers a number of events in certain circumstances. All events have extra data attached to the event object that is passed to any event handlers

您可以使用此事件来跟踪 changeDate 日期

的事件

changeDate

Fired when the date is changed.

$("YOUR_DATE_PICKER").on("changeDate", function(e) {
    //// `e` here contains the extra attributes
    alert('hey');
});

检查这个 fiddle

你也可以这样做

<input placeholder="MM/DAY/YEAR" data-bind="value: CustomerBookingTbl.PickUpDate" class="input date" name="pickupdate" onchange="UpdatePrice(this)" type="text" required>

<script>
function UpdatePrice(_this) {           
  console.log(_this.value);
}
</script>

非常简单的解决方案

现场演示:https://jsfiddle.net/jalayoza/pyc1vp19/3/

希望对您有所帮助