gpt4 book ai didi

javascript - 日期功能未按预期工作

转载 作者:行者123 更新时间:2023-11-30 12:28:49 25 4
gpt4 key购买 nike

我正在尝试将当前年份插入版权声明中,但它不起作用 - 可能是因为一些非常基本的东西。有什么帮助吗?谢谢。 :)

ps 如果还有其他文体问题,欢迎大家评论。

$(document).ready(function ()
{
// Veterinary Calculator Code
// define variables for body weight, dehydration and ongoing losses
$bw = $('#bodyWeight');
$dh = $('#dehydration');
$ol = $('#ongoingLosses');
// update maint, replacement, dailyRequirement and rate when bw, dh or ol changes.
function updateDetails()
{
var $dr = $('#dailyRequirement');
var $repl = $('#replacement');
var $rt = $('#rate');
var ol = parseInt($ol.val());
var mt = parseInt(1.5 * (70 * (Math.pow($bw.val(), 0.75)))); // maintenance requirement
$dr.text(mt + ' ml/24 hours');
var rep = parseInt($bw.val() * 10 * $dh.val()); // replacement amount
$repl.text(rep + ' ml');
var rt = parseInt((mt + rep + ol) / 24); // total fluid rate
$rt.text(rt + ' ml/hr');
}
// add event listeners for input elements

$bw.on('change', updateDetails);
$dh.on('change', updateDetails);
$ol.on('change', updateDetails);
// Insert current year into copyright statement
var dateNow = new Date();
var thisYear = dateNow.getFullYear();
var elYear = $('#currentYear');
elYear.text = thisYear;
});
	<body>
<div>
<header>
<h1>Fluid Calculator</h1>
</header>


<div>
<fieldset id="params">
<legend>Inputs</legend>
<label>Body Weight (kg):</label><br />
<input type="number" id="bodyWeight" autofocus min="0" />
<br><br />
<label>% Dehydration:</label><br />
<input type="number" id="dehydration"/>
<br /><br />
<label>Ongoing Losses (ml):</label><br />
<input type="number" id="ongoingLosses" />
<br /><br />

</fieldset><br />

<label>Daily Requirement:</label> <label class="result" id="dailyRequirement">0 ml</label> <br />
<label>Replacement:</label> <label class="result" id="replacement">0 ml</label> <br />


<br />
<label> Rate (ml/hr):</label> <label class="result" id="rate">0 ml/hr</label>
</div>

<footer>
<p>
&copy; Copyright 2014-<span id="currentYear">year</span> by VETsharp Pty Ltd
</p>
</footer>
</div>
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="vc.js"></script>

</body>

最佳答案

$("#currentYear").text(thisYear);

关于javascript - 日期功能未按预期工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28388780/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com