You save some bytes by avoiding the .attr
altogether by passing the properties to the jQuery constructor:
var img = $('<img />',
{ id: 'Myid',
src: 'MySrc.gif',
width: 300
})
.appendTo($('#YourDiv'));