/ Published in: jQuery
A jQuery plugin that will add a 'new' icon next to files that are newer than X amount of days.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
(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); });
URL: http://www.nealgrosskopf.com/tech/thread.php?pid=58