I try to change a value of an attribute "data-published" of every <a>
element to one changed by romString function that is changing format of date. What am I doing wrong?
<script>
$(function(){
var id='139540263@N06';
var tag = document.getElementById('html').getAttribute("data-tag");
// Flickr Photostream feed link.
$.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?id=" + id + "&tags="+ tag + "&lang=en-us&format=json&jsoncallback=?",
function(data){$.each(data.items,
function(i,item){
// Number of images to show.
if(i < 4){
var newTaken=new Date(item.date_taken.replace("T"," ").replace("Z","").replace("-08:00","")).getTime();
alert(newTaken);
// Create images and append to div id flickr and wrap link around the image.
$("<img/>").attr("src", item.media.m.replace('_z', '_c')).appendTo("[data-tag=html]").wrap("<a href='" + item.media.m.replace('_z', '_c') + "' name='"+ item.link + "' title='" + item.title + "'data-taken='" + newTaken + "'data-published='" + item.published.replace("T"," ").replace("Z","") + "'></a>");
}
});
});
});
</script>
Now it alerts that newTaken is NaN. Do you know why?