var bg_img = curr_elem.style.backgroundImage || curr_elem.style.getAttribute("background-image");
This returns null if curr_elem
has this property set in <style>
tag and not like this: style = "background-image: url(blah.png);"
in element itself.
So, how I can know if some background-image is applied to this element in code?
We can use getComputedStyle in IE9+, but I need this for IE6+
<html>
<head>
<title>test clone elements</title>
<style type ="text/css">
#banner-map-225 .banner-map
{
background-image: url(test_bg.jpg);
}
</style>
</head>
<body>
<div id = "banner-map-225" ></div>
<div id = "inline_styled_div" style = "background-image: url(test_bg.jpg);" ></div>
<input type = "button" value = "test first div" onclick = "alert(document.getElementById('banner-map-225').style.backgroundImage);" />
<input type = "button" value = "test second div" onclick = "alert(document.getElementById('inline_styled_div').style.backgroundImage);" />
</body>
</html>