Marksyw Marksyw - 1 year ago 122
Javascript Question

Get CSS background-image url from ID

how to get the url from this ID

<div id="image" style="background-image: url(/">

Has been searching google and stack overflow for this but only getting "get id from url" or current window location result only.

Answer Source

You can use element style backgroundImage property:

var img = document.getElementById('image'),
    url =;

<div id="image" style="background-image: url(/">

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download