Jump to content

jquery get child atribute img src


funstad

Recommended Posts

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")

Link to comment
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.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...