首页 新闻 会员 周边

jQuery 如何点击开始,暂停/继续,结束来动态更新时间

0
悬赏园豆:30 [已关闭问题] 关闭于 2018-10-01 21:32

<html>
<title>无标题文档</title>
<style type="text/css">
</style>
<script src="jquery-3.3.1.min.js">
</script>
<script type="text/javascript">
$(function(){
var sam =100000;

    setTimeout(function(){
        var now = new Date();
        var mine = now.getMinutes();
        var sec = now.getSeconds();
        $("span").html(mine+":"+sec);
        alert(sam);
    },sam);
    
    $("input").click(function(){
        alert("开始");
        sam = 1000;
    });
});

</script>
</head>

<body>
<span>00:00</span>
<input type="button" value="开始" />
</body>
</html>

绿染的主页 绿染 | 初学一级 | 园豆:159
提问于:2018-10-01 16:41
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册