I am trying to filter certain html element using the datetime attributes. My html elements looks like
<time title="Sat Dec 22 16:29:21 2012 UTC" datetime="2012-12-22T16:29:21+00:00">4 hours</time>
Now, what I am doing is
var x = $("p time").map(function() { filter(this);})
and my filter function looks like:
function filter(var1){
var now = new Date();
var time = $(var1).attr("datetime");
var time = new Date(time);
var diff = now - time;
if( diff < 7200000){
console.log("yes");
return $(var1).parent().parent();
}
}
When I run the above code I get x as an empty array and yes is printed 9 times.
So, my question is why my filter function is not returning the parent html tag.
returnfrom the function you pass tomap()