Return to Snippet

Revision: 17536
at September 9, 2009 08:07 by neal_grosskopf


Initial Code
(function($){
	$.fn.newClass = function(attr,classname,offset,debug){
		var now = new Date();
		var day = 1000*60*60*24;

		return this.each(function(i){
			var old = new Date($(this).attr(attr));
			var diff = Math.floor((now.getTime() - old.getTime()) / day);
			if(diff < offset) $(this).addClass(classname);
			if(debug) $(this).append(" - " + diff + " day(s)"); //testing
		});
	}
})(jQuery);

$(document).ready(function(){
	$("#content a").newClass("rel","new",90,true);
});

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

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

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

Initial Tags
css, jquery

Initial Language
jQuery