Reputation: 37
I have 7 divs each one with a different background-image and I need to get the url of each background image passed inline in the html, can someone help me with that?
I've tried different ways but with no success :(
Upvotes: 1
Views: 179
Reputation: 2275
use .each to cycle through all the div, to get background images.
$("div").each(
function(index) {
var thisUrl = $(this).css("backgroundImage");
var content = $("p").html(); // current content
$("p").html(content+" "+thisUrl);
}
);
Upvotes: 1