如何捕捉文本「複製我」並將其附加到ID「#copy」中?如何將文本從一個跨度附加到另一個跨度?
<span id="text">Copy me</span>
<span id="copy"></span>
如何捕捉文本「複製我」並將其附加到ID「#copy」中?如何將文本從一個跨度附加到另一個跨度?
<span id="text">Copy me</span>
<span id="copy"></span>
您可以使用此
$("#copy").append($("#text").text());
<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>
$('#copy').html($('#text').text());
<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>
$('#copy').text($('#text').text());
<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>