Aus*_*can 1 html javascript countdown
我是Java的新手,对此不太了解。但是,我设法创建了一个倒计时计时器,该计时器可以像我希望的那样正常工作。这很简单,但是基本上它是一个倒计时到特定日期的计时器,一旦到达指定的日期和时间,它就会显示我可以自定义的文本。我希望这段代码能够在倒数到零时显示带有超链接的按钮。这是我到目前为止的代码:
// Set the date we're counting down to
var countDownDate = new Date(Date.now() + 20000).getTime();
// Update the count down every 1 second
var x = setInterval(function() {
// Get todays 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);
// Output the result in an element with id="demo"
document.getElementById("demo").innerHTML = days + " days, " + hours + " hours, " +
minutes + " minutes, & " + seconds + " seconds";
// If the count down is over, write some text
if (distance < 0) {
clearInterval(x);
document.getElementById("demo").innerHTML = "We're Live on Facebook!";
}
}, 1000);Run Code Online (Sandbox Code Playgroud)
<p id="demo" class="countdown-live" style="text-align:center;"></p>Run Code Online (Sandbox Code Playgroud)
任何帮助此操作以显示超链接按钮而不是文本“ We're Live on Facebook!”的帮助。将不胜感激。
在innerHTML()属性中,您可以传递HTML标签,例如
<a href="...">
<button> YOUR TEXT </button>
</a>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
225 次 |
| 最近记录: |