Assuming I insert anything in my DOM with jQuery, like so:
$(\'#someselector\').prepend(\'\');
Make it into an jQuery object before prepending it:
var $img = $('<img src="/img/myimage.gif" id="someid" />');
$('#someselector').prepend($img);
$img.foo();
You can try something like this:
$('#someselector')
.prepend('<img src="/img/myimage.gif" id="someid" />')
.find('#someid');
Or if there's only one img:
$('#someselector')
.prepend('<img src="/img/myimage.gif" id="someid" />')
.find('img');
Alternatively:
$('<img src="/img/myimage.gif" id="someid" />').prependTo('#someselector')
Solution without creating a jQuery object before and without having an Id:
var $img = $('#someselector')
.prepend('<img src="/img/myimage.gif" />')
.find(':first');