So I just decided to play with jquery, wrote this code:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <link rel="stylesheet" type="text/css" href="style.css"> <script src="jquery-2.2.3.js"></script> </head> <body> <div id="message_area"></div> <textarea id="for_send" title="Test"></textarea> <button id="send">Submit</button> <script src="script.js"></script> </body> </html> It was html, here is js:
$(document).ready(function(){ $("#send").click(function(){ var text; text = $("#for_send").val(); $('#message_area').append('<div></div>').text(text).addClass('.message'); }); }); The task is as follows: I try to insert messages (text from a div) into a window with messages (#message_area). Everywhere, the append () method is described ... inserts the append ... element into the end of the content of the element for which I have something not like this: the content is not recorded, but replaced; is not inserted at the end, and the previous contents of #message_area are removed and a new one is inserted from #for_send. I've been sitting on this for a long time and I don’t understand what the problem is. The textarea dimensions are specified in the css file