Skip to content Skip to sidebar Skip to footer

Add Image To Textarea Onclick

I am trying to add each different image I click on into the textarea, but I can only get the first image to add. Just to add I am using Owl Carousel. So here is what the html looks

Solution 1:

If

The HTML above gets duplicated for every image that is displayed.

is completely true, you will have the id images_available in your DOM multiple times. Ids have to be unique though. You always get the first one because

document.getElementById('images_available');

will always get you the first element with this id since it doesn't expect any others in the DOM.

You should be able to fix this by just using this instead of someimage:

var myimg = this.getElementsByTagName('img')[0];

Post a Comment for "Add Image To Textarea Onclick"