I am trying to select all portlet elements that are due today and add them to the class highlight. The problem is, that it adds the class to all portlet elements if it finds one that is due today, not only to the due portlet. It doesn´t work neither with a for loop, nor with the jQuery each().
$("#todayBugs").click(function (){
var d = new Date();
var portlet = $(".portlet");
var twoDigitMonth = ((d.getMonth().length+1) === 1)? (d.getMonth()+1) : '0' + (d.getMonth()+1);
var today = (twoDigitMonth + '/' + d.getDate() + '/' + d.getFullYear());
/*for(var i=0; i<=count; i++) {
if(today == $("#datepicker").val()) {
$(portlet[i]).addClass("highlight");
}
}*/
$(portlet).each(function () {
if(today == $("#datepicker").val()) {
$(this).addClass("highlight");
}
})
});
Aucun commentaire:
Enregistrer un commentaire