GithubHelp home page GithubHelp logo

qianduanmei / lately Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tokinx/lately

0.0 2.0 0.0 23 KB

基于jQuery ,仅 800 字节却强大、好用的'Timeago'插件

Home Page: https://tokinx.github.io/lately

HTML 31.56% JavaScript 12.78% CSS 55.66%

lately's Introduction

Lately.js

基于jQuery ,仅 800 字节却强大、好用的'Timeago'插件

获取

你可以直接访问Lately.js的 GitHub 来获取最新版插件,当然你也可以通过下面的链接下载Lately.js:

lately.js or lately.min.js

引用

首先确保你的页面已经正确引用jQuery(建议2.0+),然后再引用ViewImage.js。

<script src="//tokinx.github.io/lately/lately.min.js"></script>

启用

我们为您提供了非常简便的初始化方法,方便您对程序进行一些个性化设置并正确启用

<script>
    jQuery(document).ready(function () {
        $.lately({
            'target' : '.lately-a,.lately-b,.lately-c'
        });
    });
</script>
//datetime
<time class="lately-a" datetime="2016-09-28T23:49:41+00:00" itemprop="datePublished" pubdate>2016-September-28</time>

//title
<a href="#" class="lately-b" title="2017-02-14 18:56">Any string</a>

//html
<a href="#" class="lately-c">2017-02-12 21:39</a>

上方代码执行效果参考如下:

datetime: 4个月前 / title:49分钟前 / html:1天前

Time格式

支持可直传JavaScript new Date() 对象的时间格式。

本地化

插件默认为 “简体中文” 语言,但是我们提供了非常简单的接口,方便您的本地化修改。

您可以在初始化的时候连同语言一起设置:

<script>
    jQuery(document).ready(function () {
        $.lately({
            'target' : '.lately-a,.lately-b,.lately-c',
            'lang': {
                'second': ' Second',
                'minute': ' Minute',
                'hour': ' Hour',
                'day': ' Days',
                'month': ' Month',
                'year': ' Years',
                'ago': ' Ago',
                'error': 'NaN'
            }
        });
    });
</script>

lately's People

Contributors

tokinx avatar

Watchers

James Cloos avatar 前端美 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.