How to set DIV dimensions as per the height and width of background-image
<p>I have a DIV with background-image. But my requirement is how can I extend the DIV size according to the height and width of background-image. I have tried some code with the help of <a href="http://stackoverflow.com/questions/623172/how-to-get-image-size-height-width-using-javascript">this</a> link.</p>

<pre><code>var src = $('#divID').css('background-image').
                      replace('url', '')
                     .replace('(', '')
                     .replace(')', '')
                     .replace('"', '')
                     .replace('"', '');
$('body').append('&lt;img id="appendedImg" src="' + src + '" style="height:0px;width:0px"');
var img = document.getElementById('appendedImg');       
var width = img.clientWidth;
var height = img.clientHeight; 
$('#appendedImg').detach();
</code></pre>

<p>I am just looking for any elegant solution if possible.</p>
