-2

I want to make jquery get the image source.

My html code :

<img class="img" src="photo src">

My jquery code :

$("<a href='i want to get the photo source in here' download>download</a>").appendTo('.img');

note : the html code is running outside the script tag

Anant Kumar Singh
  • 68,309
  • 10
  • 50
  • 94

1 Answers1

0

this code return full image address

<img src="../images/pic.png" />

$('img')[0].src //return https://stackoverflow.com/images/pic.png

$('img').attr('src') //return ../images/pic.png
Farhad Bagherlo
  • 6,623
  • 3
  • 23
  • 45