2

有人可以告诉我为什么倒计时功能无法正常工作(倒计时不是在 ID 为“倒计时”的 div 中开始)。可能真的很简单,但 Javascript 不是我的强项。这是我正在使用的倒计时插件:http: //keith-wood.name/countdown.html

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Page Title</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="./css/web-style-second.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="chrome://mozbar/skin/css/injected.css">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.countdown.js"></script>
</head>
<body>
<a name="top"></a>
<div id="container">
    <div id="content">  

<div class="center">
    <center>
        <div></div>
    </center>
</div>

<script type="text/javascript"> 
$(function() {
    $('#countdown').countdown({
        until: '14min+20sec',
        format: 'MS',
        layout: '{mnn}min  ' + '{snn}sec  ',
        onExpiry: function() {
            $(".hidden").css("display", "block");
        }
    });
});
</script>

<div class="time_box"> 
    <h3 class="italic">When The Clock Hits Zero ... </h3> 
    <h4 class="hasCountdown" id="countdown">14min  20sec  </h4>  
</div>

<form name="signupFrm" id="signupFrm" action="#" method="post" class="hidden">
    <div>
        <div class="yellow_red">
            <h1></h1>
        </div>
        <div class="center">
            <a href="https://www.testing.com" class="btn_buy_now">
            Get Started</a>
        </div>
        <input name="submit" value="submit" type="hidden">
        <p class="mb_5">&nbsp;</p>
    </div>
</form>
<div class="fnote justify">
</div>


    </div>
    <div id="footer">
    </div>
</div>


</body>
</html>
4

3 回答 3

0
于 2013-01-02T01:25:46.303 回答
0

倒计时插件使用该类hasCountdown来测试倒计时是否已经被实例化,因此您应该使用不同的类名。

来自 jquery.countdown.js:

/* Class name added to elements to indicate already configured with countdown.*/
markerClassName: 'hasCountdown'
于 2013-01-02T01:41:01.607 回答
0

您应该将$(function () ...)脚本放入<head>HTML 页面的标记中。这样,一旦 DOM 完全加载,就会开始倒计时。

于 2013-01-02T00:33:42.873 回答