jqExpire - A jQuery plugin to automatically hide page elements after an 'expiry' date and/or time.

A jQuery plugin to automatically hide page elements after an 'expiry' date and/or time. Great for pages which have upcoming/ongoing event notices or cut-off times for forms and such.

Expiry dates and times can be set via data attributes or invoked via function calls on individual elements. The script checks the expiry time against the local system time and hides the expired elements.

How it works

When invoked, jqExpire checks if the current local system time (the client side) is equal to or has passed the expiry time on an element and, if past, calls a jQuery hide() on it.

jqExpire doesn't set any JavaScript timeouts or intervals. It only checks the times once invoked. If you want live expiry of elements, you can set your own intervals and call jqExpire periodically.

Further versions will issue a callback upon hiding and also let you choose/specify a custom animation instead of the default.

 

This is element 1. It has no expiry.

This is element 2. This expires when 2013 ends. It should be hidden now.

This is element 3. This should be also be hidden when 2014 starts, but it is done so via a jQuery call.

This is element 4. This should be visible, but the earlier two must be hidden. View source to check.

This file demonstrates the use of the jqExpire jQuery plugin by Aalaap Ghag.