[英]Can't change font-weight in innerHTML text on Laravel
我在我的 Laravel 5 应用程序中实现了倒计时,我希望更改其文本的字体粗细。 出于某种原因,这个简单的任务让我花了很多时间来弄清楚。 任何帮助将不胜感激。
刀片.php文件
<a style="color: #fff" href="">
<div id="countdown-component" style="display:inline;color:#EC1B33;font-weight:600;letter-spacing:2px;">
</div>
</a>
JS function 生成倒计时:
<script>
// Set the date we're counting down to
var countDownDate = new Date("Feb 15, 2022 12:00:00").getTime();
// Update the count down every 1 second
var x = setInterval(function() {
// Get today's date and time
var now = new Date().getTime();
// Find the distance between now and the count down date
var distance = countDownDate - now;
// Time calculations for days, hours, minutes and seconds
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
// Display the result in the element with id="demo"
document.getElementById("countdown-component").innerHTML = days + " DAYS " + hours + " HOURS "
+ minutes + " MINUTES " + seconds + " SECONDS ";
// If the count down is finished, write some text
if (distance < 0) {
clearInterval(x);
document.getElementById("countdown-component").innerHTML = "EXPIRED";
}
}, 1000);
</script>
提前致谢。
// Set the date we're counting down to
var countDownDate = new Date("Feb 15, 2022 12:00:00").getTime();
// Update the count down every 1 second
var x = setInterval(function () {
// Get today's date and time
var now = new Date().getTime();
// Find the distance between now and the count down date
var distance = countDownDate - now;
// Time calculations for days, hours, minutes and seconds
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
var hours = Math.floor(
(distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)
);
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
// Display the result in the element with id="demo"
document.getElementById("countdown-component").innerHTML =
days +
" DAYS " +
hours +
" HOURS " +
minutes +
" MINUTES " +
seconds +
" SECONDS ";
// If the count down is finished, write some text
if (distance < 0) {
clearInterval(x);
document.getElementById("countdown-component").innerHTML = "EXPIRED";
}
}, 1000);
<a style="color: #fff" href="">
<div
id="countdown-component"
style="
display: inline;
color: #ec1b33;
font-weight: 400;
letter-spacing: 2px;
"
></div>
</a>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.