Copy element attribute values to new element
I would like to change all img tags with a certain class on the page as follows:
<img class="ChangeMe" src="some_image_file" >
to
<div class="NewDiv" style="background: url(some_image_file) no-repeat;" >
<img class="ChangeMe" src="some_image_file" style="opacity:0" >
</div>
The following gets me everything except the background url style attribute:
$('img.ChangeMe').css('opacity', '0').wrap('<div class=NewDiv></div>');
I do not know how to "copy" the value of the img tag src attribute to the background url attribute of the div.
Any help would be appreciated.
Todd