I go through many problems regarding this,But couldn't find clear answer. I have image tag like this
<img src="images/abc.jpg"/>
But when I called in side javascript,
var imgs = document.getElementsByTagName("img");
alert(imgs[0].src);
it shows the src as "http://localhost/myProject/images/abc.jpg" But I need only get the relative path ("images/abc.jpg")some how. Some body help me...
You may try to get the element src
attribute value, not the src
property:
imgs[0].getAttribute("src"); // "images/abc.jpg"
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