I have to use dynamically created images for my projekt. I do this with jQuery:
var img = $('<img />').attr({ 'id': i, 'src': e.files[i].thumbnails["200x200"], 'alt':e.files[i].name, 'class': 'photo'}).appendTo($('#img'));
But I can't run a function if the image is clicked. I tried:
$(document).ready(function() {
    $(".photo").click(function(){
        alert('Works!');    
    });
};
and onClick:
var img = $('<img />').attr({ 'id': i, 'src': e.files[i].thumbnails["200x200"], 'alt':e.files[i].name, 'class': 'photo', 'onClick': 'test();' }).appendTo($('#img'));
[...]
function test(){
   alert('Works!');
}
But both ways aren't working... What did I wrong?
 
     
     
    