I want to place the elements of a select to a textarea, the code that I have works well to add the text, but the problem arises when deleting the textarea text, if I delete something from it, it does not let me reposition more text from the select, then I put the code that I have.
function agregar(texto){
console.log(texto);
$("#test1").append(texto+"\n");
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<script src="https://code.jquery.com/jquery-3.1.0.js"></script>
<title>Problema</title>
</head>
<body>
<select name="" id="test" onchange="agregar($('#test option:selected').text())">
<option value="1">Uno</option>
<option value="2">Dos</option>
<option value="3">Tres</option>
<option value="4">Cuatro</option>
</select>
<br/>
<textarea name="" id="test1" cols="30" rows="10"></textarea>
</body>
</html>
How could I solve this problem, or why is this?