Reputation: 13223
I have a textarea in my html page. It also has a button. When I click on that button i need to copy some text in the text area.
This is working properly.
After i click on copy, If I now remove or edit some text in text area and If i click on copy again text is not getting copied.
Please help.
Below is the HTML code.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<textarea cols="20" rows="20" name="mytext" id="mytext">Copy here .... </textarea>
<br>
<input type="button" value= "Copy" onclick="copy();"/>
<script>
function copy(){
$('#mytext').html( $('#mytext').html() + "some sample text message ");
}
</script>
Upvotes: 0
Views: 699
Reputation: 40639
Use val() not html()
like
function copy(){
$('#mytext').val( $('#mytext').val() + "some sample text message ");
}
Upvotes: 3