SO - 21042797

by Arun P Johny

HTML

<div>
    <div class="date" id="18,9,2013">18th Sept 2013: Going Fishing</div>
    <div class="date" id="22,01,2014">22nd Jan 2014: Going on Holiday to Greece</div>
    <div class="date" id="16,02,2014">16th Feb 2014: Business Meeting</div>
    <div class="date" id="27,02,2014">27th Feb 2014: Sisters Birthday</div>
</div>

CSS

.next {
    color: blue
}

JavaScript

var today = new Date();
//clear the time part
today.setHours(0, 0, 0, 0);
//need to remove the . from the class attribute of the elements
$('.date').each(function () {
    var parts = this.id.split(",");
    var date = new Date(parts[2], parts[1], parts[0]);
    if (date - today > 0) {
        $(this).addClass('next');
        //return false to prevent the iteration of any other element
        return false;
    }
})