Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Jquery append image source after image

Posted on 2013-01-03
4
Medium Priority
?
350 Views
Last Modified: 2013-02-14
I am looking to add the image source after the image. I need to do this for every image in a div.

Example
<img src="something.jpg" />

Would become
<img src="something.jpg" />somgething.jpg
0
Comment
Question by:garyilm
  • 2
  • 2
4 Comments
 
LVL 83

Expert Comment

by:leakim971
ID: 38741628
$(document).ready(function() {

$("img").each(function() { $(this).attr("src").insertAfter(this); });

})

Open in new window

0
 

Author Comment

by:garyilm
ID: 38741684
that didn't work
0
 
LVL 83

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 38741796
new one : http://jsfiddle.net/LP4zn/

$(document).ready(function() {

$("img").each(function() { $(document.createTextNode($(this).attr("src"))).insertAfter(this); });

})¿

Open in new window

0
 

Author Comment

by:garyilm
ID: 38741862
Perfect thanks. Can this be made into a link?
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question