我有修改过的jquery版本
TimeAgo
插件..唯一的调整是我可以设置自定义属性而不是全局属性。这样做的原因是,我可以在一些标记上有一个后缀,而在其他标记上没有后缀。这种调整本身就非常有效,因为我用不同的方式测试过它。
但是,我想要选择元素/属性的方式工作不正常。
我的标记有以下内容
<time data-suffixAgo="" datetime="2010-06-24T14:10:22Z" title="2010-06-24T14:10:22Z">4 months </time>
<time data-suffixAgo="ago" datetime="2010-11-10T06:00:44Z" title="2010-11-10T06:00:44Z">less than a minute ago</time>
<!-- note the data between the <title> tags is generated server side.
I'm not talking about that data, just the jQuery information-->
运行时的输出显示
4 months ago
less than a minute ago
现在问题是“4个月前”不应该说“前”,因为我
data-suffixAgo
属性为空
这是我正在使用的jquery
// selects all "time" tags on the page and give the friendly "timeago"
// uses the jquery.timeago.js plugin
// all time tags are created using the "ToTimeSpan" Date Extension Method
$('time').timeago({strings:{suffixAgo: $(this).attr("data-suffixAgo")}});
有人能告诉我为什么选档杆不拉
数据后缀
每个元素的属性?
如果我用这个
$('time').timeago({strings:{suffixAgo: ""}});
“前”是
远离的
从所有人
<time>
标签,如果我这样做
$('time').timeago({strings:{suffixAgo: "ago"}});
“前”是
补充
对所有
<时间>
标签