[英]How to use getValue() to get date
HTML: HTML:
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">From</span>
</div>
@(Html.DevExpress().BootstrapDateEdit("dtReturnDateFrom").EditFormat(EditFormat.Custom).DisplayFormatString("dd MMM yyyy").EditFormatString("dd MMM yyyy").UseMaskBehavior(true).AllowNull(false).Value(@DateTime.Today - TimeSpan.FromDays(365)))
</div>
jQuery jQuery的
$(document).ready(function () {
$M.Report.onLoadReport = function (varReportNm, varTemplateNm) {
dtTempReturnFrom = $('#dtReturnDateFrom').getValue();
dtTempReturnTo = $('#dtReturnDateTo').getValue();
tempReturnFrom = dtTempReturnFrom.getFullYear() + "-" + dtTempReturnFrom.getMonth() + "-" + dtTempReturnFrom.getDay();
return {
/////////// addd this
format: varTemplateNm,
dtReturnDateFrom: tempReturnFrom,
};
}
});
The error that I get. 我得到的错误。
I have try find the solution at google but most the solution was not work with my code. 我尝试在Google找到解决方案,但大多数解决方案不适用于我的代码。
GetValue is not a function GetValue不是函数
$('#dtReturnDateFrom')
will be a jquery object & in jequery there is no getValue()
function .Use val()
insetad of getValue();
$('#dtReturnDateFrom')
将是一个jquery对象,在jequery中没有getValue()
函数。使用val()
getValue();
insetad getValue();
If you wish to create a custom function getValue
you need to extend jquery and create a function getValue
and define it's body 如果要创建自定义函数getValue
,则需要扩展jquery并创建函数getValue
并定义它的主体
jQuery.fn.extend({ getValue: function() { return $(this).val(); } }); let k = $('#someId').getValue(); console.log(k)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <input type='text' id="someId" value="test Value ">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.