TTT
TTT

Reputation: 37

Get background-image url value

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

Answers (1)

aahhaa
aahhaa

Reputation: 2275

http://jsfiddle.net/e46bf/

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

Related Questions