js实现点击按钮后延长倒计时时间
1个回答
展开全部
<p></p>
<input type="button" value="提交" onclick="test()">
<script>
var count = 1800;
var p = document.querySelector('p')
var intervalId = window.setInterval(countDown, 1000)
function countDown() {
--count
p.innerText = timeFormat()
}
function test() {
count += 60 * 60
p.innerText = timeFormat()
}
var hour, minute, second
var timeText;
function timeFormat() {
hour = Math.floor(count / (60 * 60));
minute = Math.floor(count / 60) - (hour * 60);
second = Math.floor(count) - (hour * 60 * 60) - (minute * 60);
timeText = hour + ':' + minute + ':' + second
return timeText
}
</script>
我就提供一种思路吧。代码如上:
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询