首页javascriptelementJavascript DOM - 如何追加克隆元素

Javascript DOM - 如何追加克隆元素

我们想知道如何追加克隆元素。

<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.4.2.js'></script>
<script type='text/javascript'>
$(window).load(function(){
    console.log($('<div>').append( $("span").clone() ).html());
});
</script>
</head>
<body>
  <span id='kuku' class='lala bubu' value='xyz'>some text</span>
  <p>Stuff in the middle</p>
  <span id='kuku' class='lala bubu' value='xyz'>other</span>
</body>
</html>