<p><span>The "06/03 somestuff 1" listitem is hidden by JavaScript when the page is ready.</span></p>
<div>
<ul id="whatson">
<li><span class="chkdate">06/03</span> somestuff 1</li>
<li><span class="chkdate">06/04</span> somestuff 2</li>
<li><span class="chkdate">06/05</span> somestuff 3</li>
</ul>
</div>
CSS
body { font-family:"Consolas" }
JavaScript
$(document).ready(function () {
var todaysdate = new Date();
var datestocheck = $('#whatson li').each(function (i, v) {
var listitem = $(v); var chkdate = $('span', listitem);
var stringdate = chkdate.text();
var monthtocheck = stringdate.split('/')[0];
var daytocheck = stringdate.split('/')[1];
var datetocheck = new Date();
datetocheck.setFullYear(
todaysdate.getFullYear(), // four digit year
monthtocheck-1, // month number minus 1 b/c month is 0-11
daytocheck // the day number
);
//alert(datetocheck + ' < ' + todaysdate);
if (datetocheck < todaysdate) {
listitem.hide();
} else {
listitem.show();
}
});
})
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.