Tying click event to a variable

Tying click event to a variable

I have a setting where I construct an image reference which I then append somewhere in the DOM, like so for instance:

var one = "<img src = \"test.jpg\" ";
var two = "/>";

var my_img = one + two;

and then I add it to DOM using after() function.  It works fine.  However, I also need to add a click event to it.  I tried to do this:

my_img.click(function(){

});

and then append it using after(), but it doesn't seem to work.  One thing I can think of is append it after a certain ID, then look for it as a child of that ID and add click to it this way.  I haven't tried this, but it'll probably work.  However, this strikes me as a bit heavy handed. Is there a better way of doing this?

Thanks!
Luka