test.html•2.42 kB
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
#button {
margin: 20px;
width: 100px;
height: 100px;
background: yellow;
}
#button2 {
margin: 20px;
width: 100px;
height: 100px;
background: greenyellow;
}
#button3 {
margin: 20px;
width: 100px;
height: 100px;
background: red;
}
</style>
</head>
<body>
<h1 id="h1"></h1>
<div id="button">暂停</div>
<div id="button2">恢复</div>
<div id="button3">结束</div>
</body>
<script src="dist/CountDown.min.js"></script>
<script>
// CountDown.openTimeCountBySeconds({
// Ele: document.getElementById('h1'),
// CountDownSeconds: 3600,
// Sign: 'flypie',
// Divider: ':',
// EndFunc: function () {
// console.log('end');
// }
// });
var startDate = new Date();
var endDate = new Date();
endDate.setSeconds(startDate.getSeconds() + 20);
// CountDown.openDateAndTimeCountByStartAndEndDate({
// Ele: document.getElementById('h1'),
// StartDate: startDate,
// EndDate: endDate,
// Sign: 'flypie',
// Divider: ':',
// DateDivider: '天 ',
// EndFunc: function () {
// console.log('end');
// }
// });
CountDown.openTimeCountByStartAndEndDate({
Ele: document.getElementById('h1'),
StartDate: startDate,
EndDate: endDate,
Sign: 'flypie',
Divider: ':',
EndFunc: function () {
console.log('end');
},
additionToggle: {
seconds: 10,
callback: function () {
alert('soon');
}
}
});
var e_button = document.getElementById('button');
e_button.addEventListener('click', function () {
CountDown.stopBySign('flypie');
});
var e_button2 = document.getElementById('button2');
e_button2.addEventListener('click', function () {
CountDown.resumeBySign('flypie');
});
var e_button3 = document.getElementById('button3');
e_button3.addEventListener('click', function () {
CountDown.closeBySign('flypie');
});
</script>
</html>