Skip to content
Advertisement

Create code template from input javascript

I’m trying to make app that generates code with HTML tags from images.

User pastes an image link, image displays and after that user will click button to generate the img code to copy.

I’ve got code that loads and previews images from input.

I’m struggling with generating the HTML code. User will get: <img src="link photo"> in div code.

I can’t make it:

JavaScript

Because it won’t display HTML tags.

JavaScript

Advertisement

Answer

Don’t use innerHTML, use innerText:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement