Question

I can't seem to get the jquery time ago plugin to work.

Here is my code

<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="jquery.timeago.js"></script>
</head>

<body>
 <abbr class="timeago" title="19 March 2013 04:51:33 PM"></abbr>
</body>
</html>

It don't seem to be working...

Was it helpful?

Solution

you have to initiate the plugin like this

jQuery(document).ready(function($){
 $("abbr.timeago").timeago()

});

the final code will be like this

<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="jquery.timeago.js"></script>
</head>

<body>
 <abbr class="timeago" title="19 March 2013 04:51:33 PM"></abbr>

    <script>
    jQuery(document).ready(function($){
     $("abbr.timeago").timeago()

    });
    </script>

</body>
</html>

hope this helps

OTHER TIPS

Add this to your page:

jQuery(document).ready(function() {
  jQuery("abbr.timeago").timeago();
});

Make sure you follow the instructions from http://timeago.yarp.com/ (See How? section)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top