jQuery - Add text in textarea without removing previous text
Posted: 31 Jan 2015, 15:38
How to add (append) text in textarea using jquery without removing previous text?
I have this code, but it only works for first time, when i change something in textarea and click again it does nothing.
I have this code, but it only works for first time, when i change something in textarea and click again it does nothing.
Code: Select all
<form action="#" method="post">
<textarea name="cnt1" id="cnt1"></textarea><br/>
<input type="text" name="txt1" id="txt1" />
<input type="button" value="Add" id="btn" />
</form>
<script>
$('#btn').on('click', function (){
var insertText = $('#txt1').val();
$('#cnt1').append(' '+ insertText);
});
</script>