0

我的 html 页面中有一个文本区域。它还有一个按钮。当我单击该按钮时,我需要在文本区域中复制一些文本。

这工作正常。

单击复制后,如果我现在删除或编辑文本区域中的某些文本,并且如果再次单击复制,则文本不会被复制。

请帮忙。

下面是 HTML 代码。

<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>
4

1 回答 1

3

使用val()html()喜欢

function copy(){
    $('#mytext').val(  $('#mytext').val() +  "some sample text message ");
}
于 2013-08-02T12:04:08.400 回答