ok well you cannot start and id with a number. your image alreayd has an id of bg, you want to change the id of bg?
Code:
<script>
$(function() {
var images = ["chococat.gif","comic.gif","devil.gif","eye.gif"];
$('<img>').attr({'src':''+images[1],'id':'bg','title':''}).appendTo('#bg-wrapper').parent().fadeIn(1000);
$('.change').click(function(e) {
e.preventDefault();
var ranImgNum = Math.floor(Math.random()*images.length)
var image = images[ranImg];
$('#bg').parent().fadeOut(800, function() {
$('#bg').attr({'src':image, 'id':'ranimageid'+ranImgNum});
$(this).fadeIn(800);
});
});
});
</script>
if you want to change the id of bg, this will do it