我刚开始学习javascript 2周,所以我对它非常陌生。我不能让时间从http://timeago.yarp.com/开始工作!我不明白这条指令:
现在,让我们将它附加到DOM准备好的时间戳上:
jQuery(document).ready(function() {
jQuery("abbr.timeago").timeago();
});“DOM上的时间戳准备好了吗?”到目前为止,这是我想出来的,但不起作用。
<html>
<head>
<script src="jquery.min.js" type="text/javascript"></script>
<script src="jquery.timeago.js" type="text/javascript"></script>
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery("abbr.timeago").timeago();
});
</script>
</head>
<body>
<abbr class="timeago" title="2008-07-17T09:24:17Z">July 17, 2008</abbr>
</body>
</html>编辑:--我在第三个脚本标记中添加了双引号,但仍然无法工作。密码
<abbr class="timeago" title="2008-07-17T09:24:17Z">July 17, 2008</abbr>是取自http://timeago.yarp.com/中提供的示例。
我应该看到的日期显示为两年前,但我看到的是2008年7月17日。我在WAMP上测试这个。
发布于 2011-02-11 04:39:15
忘记更改src
<script src="jquery.min.js" type="text/javascript"></script>至
<script src="jquery-1.4.4.min.js" type="text/javascript"></script>一个值得认错的人,我想我必须从中吸取教训:)
发布于 2011-02-11 04:21:12
正如@Box9 9在一条评论中所指出的(为什么人们会在评论中添加答案?),您的第三个<script>标记在"javascript“之后缺少了一个结尾引号,尽管我希望HTML会足够宽容地忽略这一点。
https://stackoverflow.com/questions/4965583
复制相似问题