I have a div with a background image. But my requirement is how to increase the size of the DIV according to the height and width of the background image. I tried the code using this link.
var src = $('#divID').css('background-image'). replace('url', '') .replace('(', '') .replace(')', '') .replace('"', '') .replace('"', ''); $('body').append('<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();
I am just looking for any elegant solution, if possible.
Exception
source share