0

我在中继器(DataBound 控件)中有标签。现在我想在它上面使用count Down jquery插件。实际上我想在这里做什么我有一个像“12/07/2012”这样的日期我想计算从那个日期到现在的小时数。为此,我找到了 CountDown 插件,它将使用以下代码更新时间:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
    @import "Countdown.countdown.css";
</style>
<%--Scripts Starts from here. --%>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript" src="Countdown/jquery.countdown.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        var longWayOff = new Date();
        //longWayOff.setDate(longWayOff.getDate() + 500);
        longWayOff.setDate(longWayOff.getDate());
        var liftoffTime = new Date();
        var startYear = new Date();
        startYear = new Date(startYear.getFullYear(), 1 - 1, 1, 0, 0, 0);

        //liftoffTime.setDate(liftoffTime.getDate() + 72);
        liftoffTime.setDate(liftoffTime.getHours() + 72);
        // $('#noDays').countdown({ until: liftoffTime, format: 'HMS' });
        $('#noDays').countdown({ since: startYear, compact: true,
            format: 'HMS', description: ''
        });
    });
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<span id="noDays" class="countdown"></span>
</div>

现在,当我尝试对转发器使用相同的代码时,它无法正常工作,因为它无法找到标签。然后我使用 Firebug 获取运行时 ID 并为该 ID 应用脚本,它工作正常。我的问题是我们如何在中继器内使用倒计时插件作为标签。

4

1 回答 1

0

看起来中继器在 Document.Ready 之后可以在 DOM 中搜索!您可以使用 live() 函数的帮助来触发您的计时器。

您还可以尝试查看在 Document.ready 时是否存在中继器:

$(document).ready(function()
 {
  jQuery.contains(document.body, $('#Repeater'));
})
于 2012-07-14T08:14:41.777 回答