I have implemented this javascript with a hard coded date and it is displaying properly, I have tried it in a griview but it is rather showing the enddate from my database without showing the countdown, but i want to be getting the enddate from the database: Also, when the countdown is over it should display a message: "Project over" Please friends help me out.
我已经实现了这个带有硬编码日期的javascript并且显示正常,我已经在griview中尝试了它但是它显示了我的数据库的enddate而没有显示倒计时,但我想从数据库中获取enddate:此外,当倒计时结束时,它应显示一条消息:“项目结束”请朋友帮助我。
<script type="text/javascript" src="../Scripts/jquery-3.1.1.min.js"></script>
<script type="text/javascript" src="../Scripts/jquery.countdown.min.js"></script>
<script type="text/javascript" src="../Scripts/jquery.countdown.js"></script>
<asp:TemplateField HeaderText="CountDown" ItemStyle-Width="300px">
<ItemTemplate>
<div id="myCountdownClass"><%# !string.IsNullOrEmpty(Eval("EndDate").ToString()) ? Convert.ToDateTime(Eval("EndDate")).ToString("MM'/'dd'/'yyyy") : "" %></div>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<script type="text/javascript">
$(document).ready(function () {
$('.myCountdownClass').each(function () {
var date = $(this).text();
$(this).countdown(date, function (event) {
$(this).text(event.strftime('%D days %H:%M:%S'));
});
});
});
</script>
1 个解决方案
#1
0
You specified id
in your template, but you're trying to select a class in your javascript ($('.myCountdownClass')
). Change this:
您在模板中指定了ID,但是您尝试在javascript中选择一个类($('。myCountdownClass'))。改变这个:
<div id="myCountdownClass">
to this:
对此:
<div class="myCountdownClass">
Here's the working example (check script.js
file):
这是工作示例(检查script.js文件):
http://embed.plnkr.co/uffoqIjhqvvV7lzFlmzu/
http://embed.plnkr.co/uffoqIjhqvvV7lzFlmzu/
#1
0
You specified id
in your template, but you're trying to select a class in your javascript ($('.myCountdownClass')
). Change this:
您在模板中指定了ID,但是您尝试在javascript中选择一个类($('。myCountdownClass'))。改变这个:
<div id="myCountdownClass">
to this:
对此:
<div class="myCountdownClass">
Here's the working example (check script.js
file):
这是工作示例(检查script.js文件):
http://embed.plnkr.co/uffoqIjhqvvV7lzFlmzu/
http://embed.plnkr.co/uffoqIjhqvvV7lzFlmzu/