Reputation: 43647
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
Upvotes: 13
Views: 10833
Reputation: 236022
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)
Upvotes: 14