我已经从一位同事那里获得了一些Javascript(目前无法检测到),我想知道如何实际显示javascript在我的网页上创建的数字。 我已经使用
加载了javascript<SCRIPT language=JavaScript src="https://www.mywebsite.com/java/counter.js"></SCRIPT>
但是我不知道用什么html来实际给我结果。
var currStr = 0;
var targetStr = 0;
var animTimer = null;
$(document).ready(function() {
currStr = calculateCups();
$('.tea-count > .figure').html(currStr.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,"));
setInterval(anim, 1000);
});
function anim()
{
targetStr = calculateCups();
animTimer = setInterval(function()
{
if (currStr < targetStr) {
currStr += 155;
$('.tea-count > .figure').html(currStr.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,"));
}
if (currStr >= targetStr) {
clearInterval(animTimer);
}
}, 25);
}
function calculateCups()
{
var cupsNumber = 165000000;
var date = new Date();
var hours = date.getUTCHours()*60*60;
var minutes = date.getUTCMinutes()*60;
var seconds = date.getUTCSeconds();
return Math.round((cupsNumber/86400)*(hours+minutes+seconds));
}
非常感谢您的帮助!
答案 0 :(得分:0)
您可以在结束</body>
标记之前询问您的朋友或将其添加到您网页的末尾:
<script>Your code</script>