i have this
<div class="data">
<img src="#" style="background:url('o.jpg')">
</div>
i want to take this(background) url and create new img tag with src="background img url" in the same div and delete the old img tag using js or jq
i tried to do this from
var img = document.querySelector('img'),
// parse image URL and strip away url('')
imgURL = img.style.backgroundImage.replace('url("','').replace('")','');
img.src = imgURL;
// remove style attribute afterwards.
img.removeAttribute('style');
but it is not working for me so i have to do it the other way