[英]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.