transform img into backgtound img

transform img into backgtound img

how can do that with jquery

 to go from here 
  1. <div class="boximg"><img class="bgimg" scr="any.jpg" /></div>
to there

  1. <div class="boximg" style="background-image:url(any.jpg);">
  2. <img class="bgimg" style="display:none;" src="any.jpg" />
  3. </div>

all the .boximg  will find .bgimg > jpg to make a  background-image

thanks for your help