Question: i have this html

```
<div class="mytext">
blablabla
</div>

<div class="part2" data-type="background" data-speed="10">
    <img src="images/bb4.jpg" />
</div>

<div class="mytext">
hello hello world
</div>

<div class="part2"    data-type="background" data-speed="10">
    <img src="images/bb5.jpg" />
</div>   

```

now i want to get each src of the images in part2 container, and then change the html to this result

```
<div class="mytext">
blablabla
</div>

<div class="part2" style="background:url('images/bb4.jpg') fixed;" data-type="background" data-speed="10">

</div>

<div class="mytext">
hello hello world
</div>

<div class="part2" style="background:url('images/bb5') fixed;" data-type="background" data-speed="10">

</div> 

```

basicly i have to get the src and then edit the attributes of the div container, and delete the img tag ,and i have to do this on the load of the page

i've write this piece of code to get the src, but it doesn't work , and there isn't the part of changing the div

```
var elems = [].slice.call( document.getElementsByClassName("post2") );
elems.forEach( function( elem ){
    elem.onclick = function(){
        var arr = [],
            imgs = [].slice.call( elem.getElementsByTagName("img") );
        if(imgs.length){
            imgs.forEach( function( img ){
                var attrID = img.id;
                arr.push(attrID);
            });
            alert(arr);
        } else {
            alert("No images found.");
        }
    };
});

```

can someone help me?:) 
thanks

Answer: 
```
$('.part2').each(function(){
  img = $(this).find('img');  
  $(this).css({'background': 'url(' +   img.attr('src') + ') fixed'});
  img.remove();
});

```
SInce you have added Jquery tag. [**Here**](http://jsfiddle.net/HD986/2/) is the answer in jquery.

```
$('#test').click(function(){
    $('.part2').each(function(){
        $(this).attr('style','background:url(\''+ $(this).find('img').attr('src')+'\') fixed;');
        $(this).find('img').remove();
    });
});

```

or

```
 $('#test').click(function(){
        $('.part2').each(function(){
            $(this).css('background','url(\''+ $(this).find('img').attr('src')+'\') fixed');
            $(this).find('img').remove();
        });
    });

```