asp.net/jquery-倒计时计时器不起作用
题
这是完整的代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.pack.js"></script>
<style type="text/css">
@import "jquery.countdown.css";
</style>
<script type="text/javascript" src="Scripts/jquery.countdown.js"></script>
<script type="text/javascript">
$('#shortly').countdown({ until: shortly,
onExpiry: liftOff, layout: "{ps} seconds to go"
});
$(document).ready(function () {
shortly = new Date();
shortly.setSeconds(shortly.getSeconds() + 5.5);
$('#shortly').countdown('change', { until: shortly });
});
function liftOff() {
// refresh the page
window.location = window.location;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<span id="shortly"></span>
</form>
</body>
</html>
我在Visual Studio的脚本图中有jQuery.countdown.js。项目中还有样式表“ jquery.countdown.css”。
不知道问题可能是什么。我是JQuery的新手,并试图学习它。
解决方案
我不熟悉这个倒计时插件,但请尝试移动零件
$('#shortly').countdown({ until: shortly,
onExpiry: liftOff, layout: "{ps} seconds to go"
});
进入传递的功能 $(document).ready
, ,更换 $('#shortly').countdown('change', { until: shortly });
因为否则 shortly
当您尝试使用它时,VAR不会初始化。
其他提示
您的升力功能有错误 windowwindow.location
function liftOff() {
// refresh the page
window.location = window.location;
}
不隶属于 StackOverflow