Posted By

neal_grosskopf on 09/09/09


Tagged

css jquery


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

neal_grosskopf


Identify The Age Of Your Word & PDF Files Using CSS & jQuery


 / Published in: jQuery
 

URL: http://www.nealgrosskopf.com/tech/thread.php?pid=58

A jQuery plugin that will add a 'new' icon next to files that are newer than X amount of days.

  1. (function($){
  2. $.fn.newClass = function(attr,classname,offset,debug){
  3. var now = new Date();
  4. var day = 1000*60*60*24;
  5.  
  6. return this.each(function(i){
  7. var old = new Date($(this).attr(attr));
  8. var diff = Math.floor((now.getTime() - old.getTime()) / day);
  9. if(diff < offset) $(this).addClass(classname);
  10. if(debug) $(this).append(" - " + diff + " day(s)"); //testing
  11. });
  12. }
  13. })(jQuery);
  14.  
  15. $(document).ready(function(){
  16. $("#content a").newClass("rel","new",90,true);
  17. });

Report this snippet  

You need to login to post a comment.