pic_display+="<img src='"+pic_url+"' onClick='swapImage("+pic_url+");'>
I am adding an image to the innerHTML of a div with the code above.
I want to call the function swapImage(pic_url) whenever I click on the image.
I have still not figured out the syntaxes in javascript, always confuse them with php.
How should it be written ?
Thanks
You need to wrap the function argument in quotes like you have with the src attribute. For example.