I have an image tag..
<img src="/folder1/folder2/image.jpg">
I need to, using javascript / query remove the first forward slash from the src tag to make the image tag like this.
<img src="folder1/folder2/image.jpg">
I would like to do this for any image on the page.
Any thoughts?
Justin
Tested and works:
JS Fiddle demo.
As per nnnnn’s suggestion, in comments below, an alternative solution using
substring():JS Fiddle demo.
Note that I’m using:
because I want the actual contents of the attribute, rather than the browser’s evaluated interpretation of that attribute (for example with
src="/folder1/folder2/image.jpg"on jsFiddlethis.srcreturnshttp://fiddle.jshell.net/folder1/folder2/image.jpg).