Jump to content
funstad

jquery get child atribute img src

Recommended Posts

Update: when you remove the <a> tag around the image it will show the image src, but i cant remove them for my project. any ideas?

Share this post


Link to post
Share on other sites

First, if you look at your browser's console you'll notice that if you open the box and click save multiple times, it runs the save function multiple times. The first time you click save it runs it once, the second time it runs it twice, the third time it runs it 3 times, etc. That's because every time you show the edit box you attach another function to the save button. So if you show the save box 5 times then you have 5 save functions running when you click on the save button. Don't attach the event handler for the save button when you show the box, you only need to attach it once.

 

Second, add some more console.log statements. Check things like this:

 

$("#sim-edit-testtest .url")

 

and this:

 

$(".sim-edit-box-content-field-input.imgurl")

Share this post


Link to post
Share on other sites

Your click handler can figure out which element was clicked on, and if necessary you can go up the parent tree to find the relevant image. I believe that, inside most jQuery event handlers, $(this) refers to the element that fired the event.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...