This code gives something like ../movies/1.png
, the exact src attribute:
$("img").attr("src");
How do I get absolute path of an image with jQuery?
I want to get something like http://site.com/movies/1.png
, not ../movies/1.png
This can easily be done by accessing the .src
property directly on the <img>
:
$('img')[0].src;
example: http://jsfiddle.net/9mKz2/
(I didn't test it on all browser right now)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With