13

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

1

1 Answer 1

14

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)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.