-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

Alive to die - Anant
  • 70,531
  • 10
  • 51
  • 98

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,725
  • 3
  • 25
  • 47