Jasper Jasper - 1 year ago 150
Javascript Question

Get image src with jQuery

<img src="../img/arnold.png" alt="Arnold">

How do I get with jQuery absolute path of this image?

gives me just "../img/arnold.png", should give something like "http://site.com/data/2011/img/arnold.png" (full url).

Answer Source
alert( $('img')[0].src );

this might do the trick... but not sure about cross browser....

demo in here

also try prop of jQuery 1.6..

alert( $('img').prop('src') );

demo here

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