There's a lot of duplication to get
src
,name
, and so on. Simply use$.map
:var properties = $.map(["src", "name", "date", "desc"], function(id) { return xml.getElementsByTagName(id)[d].childNodes[0].nodeValue; }
Don't forget any
var
Create img using this less error-prone technique:
var img = $('<img>').attr('alt', name).attr('src', src);
Quentin Pradet
- 6.9k
- 1
- 24
- 44