如何将文本从一个跨度附加到另一个跨度?

时间:2015-10-14 14:02:20

标签: jquery

如何捕获“复制我”文本并将其附加到ID“#copy”中?

<span id="text">Copy me</span>
<span id="copy"></span>

3 个答案:

答案 0 :(得分:0)

你可以用这个

&#13;
&#13;
$("#copy").append($("#text").text());
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<span id="text">Copy me</span>
<span id="copy"></span>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

&#13;
&#13;
$('#copy').html($('#text').text());
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<span id="text">Copy me</span>
<span id="copy"></span>
&#13;
&#13;
&#13;

答案 2 :(得分:0)

&#13;
&#13;
$('#copy').text($('#text').text());
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<span id="text">Copy me</span>
<span id="copy"></span>
&#13;
&#13;
&#13;