The principle is as follows. After clicking on the button , the div was replaced with textarea and the message was sent.
<div id="message" contenteditable="true"></div> <button id="bsmile">Добавить</button> $("#bsmile").click(function() { $('div#message').each(function() { $("#message").replaceWith(function(index, oldHTML) { return $("<textarea id='message' rows='3'>" + $(this).html() + "</textarea>") .html(oldHTML); }) }); }); But if in a div some kind of html code, for example, the picture <img src="/opacity.png" in the textarea it already looks like this <img src="/opacity.png" . How to make a normal <img ?