jQuery中的计时器

我在Google中搜索了很多东西,但没有找到一个可靠的搜索引擎。这就是为什么我问这个问题。

我正在动态创建iframe和中的iframe div

我需要显示并启动TIMERcount,从[00:00:00]开始,其格式为[hh:mm:ss],在我JSP完全加载后。

因此,我使用了以下plugin http://tutorialzine.com/2012/09/count-up-jquery/

但是它在IE中对我不起作用,chromefirefox中有效..只有我得到了警告消息。除了什么都没发生,我的JSP代码是

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script src="js/jquery-1.9.1.js"></script>
<script src="js/assets/countup/jquery.countup.js"></script>

<script type="text/javascript">
    $(function() {
        alert("DOM loaded");
        $('#countdown').countup();
    });
</script>

</head>
<body>

    <h2>Timer is :</h2>

    <p id="countdown"></p>

</body>
</html>

我不明白为什么这对我不起作用。

我的需要:

  • 我需要显示并开始TIMER计数,以[hh:mm:ss]格式[00:00:00]开始,然后以指定格式将DOM完全加载到IE中。

  • 或建议我做任何其他事情以使这种情况下可行。

希望我们的堆栈用户能帮助我。

最后,我通过自己的代码找到了满足我要求解决方案

var hours = 0;
var minutes = 0;
var seconds = 0;

$(function() {
    setInterval(counter, 1000);

});

function counter() {


    var hh = 0;
    var mm = 0;
    var ss = 0;

    seconds = seconds + 1;
    ss = seconds + 1;
    if (seconds == 60) {
        seconds = 0;
        minutes = minutes + 1;
        mm = minutes + 1;
        if (minutes == 60) {
            minutes = 0;
            hours = hours + 1;
            hh = hours + 1;
        }
    }

    if (seconds < 10) {
        ss = "0" + seconds;
    }else{
        ss = seconds;
    }
    if (minutes < 10) {
        mm = "0" + minutes;
    }else{
        mm = minutes;
    }
    if (hours < 10) {
        hh = "0" + hours;
    }else{
        hh = hours;
    }

    $('#displayTime').html("[ " +hh + " : " + mm + " : " + ss+" ]");

}

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章