我需要将元素的值克隆到另一个元素
<a id="button" href="">Google</a>
我想在div上打印值
<div id="destination">Google</div>
jQuery:有了这个,所有a
标签都被克隆了!我想要克隆元素的值!
$("#button").clone().appendTo('#destination');
谢谢你的帮助
但是,有几种方法可以实现这一目标
$('#destination').html($('#button').html());
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a id="button" href="">Google</a>
<div id="destination"></div>
$('#destination').text($('#button').text());
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a id="button" href="">Google</a>
<div id="destination"></div>