I have been trying to solve this issue for two days. Maybe someone has a hint for me?
I have this couple of divs and in every div.news-list-item are 2 dates - startdate and enddate. I want to compare the two dates to check if they are equal. If they are equal then add the class show, if not do something else.
The Problem is that startDate is always empty or undefined.
<div class="news-list-container row">
<div class="news-list-item nth-item-1">
<span class="event-from">17.10.2014</span>
<span class="event-to">19.10.2014</span>
</div>
<div class="news-list-item nth-item-2">
<span class="event-from">07.12.2014</span>
<span class="event-to">07.12.2014</span>
</div>
<div class="news-list-item nth-item-3">
<span class="event-from">08.12.2014</span>
<span class="event-to">08.12.2014</span>
</div>
</div>
$('.news-list-container').each(function() {
var $children = $(this).children(),
count = $children.size(),
$item;
$children.each(function(i) {
$item = $(this).addClass('nth-item-' + (i + 1))
});
$(".news-list-item").each(function() {
var startDate = $(".event-from").val();
var endDate = $(".event-to").val();
if(startDate == endDate) {
$(this).addClass("show");
} else {
}
});
console.log("story " + startDate + " story");
});
});