I am trying to loop over some dates and based on the date only show the $titles if it has the date for today. I suspect my if statement is off but I am not sure. Checking the console I get no errors. No titles gets returned too in the console. So I am not sure where to go from here?
$('<ul></ul>').insertAfter('h1');
$.get('http://website.com/rss.php', function(data) {
var $items = $(data).find('item');
$items.each(function() {
var $item = $(this);
var $pubdate = $item.find('pubDate').text();
if ($pubdate == "Mon, 14 May 2012 19:40:40 UT") {
var $title = $item.find('title').text();
var html = '<li>' + $title + '</li>';
$(html).appendTo('ul');
}
});
});
The
$pubdatestring includes the newline, so you must include it in your comparison:http://jsfiddle.net/AlienWebguy/Y5dNc/6/