<!DOCTYPE html> <html> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <title></title> <style> .left, .right { width: 300px; height: 120px; } .left div, .right div { width: 100px; height: 90px; padding: 5px; margin: 5px; float: left; border: 1px solid #ccc; background: #bbffaa; } </style> </head> <body> <h2>通过clone克隆元素</h2> <div class="left"> <div class="aaron1">点击,clone浅拷贝</div> <div class="aaron2">点击,clone深拷贝,可以继续触发创建</div> </div> <script type="text/javascript"> //只克隆节点 //不克隆事件 $('.aaron1').on('click',function(){ $('.left').append($(this).clone().css("color","red")); }) </script> <script type="text/javascript"> //克隆节点 //克隆事件 $('.aaron2').on('click',function(){ $('.left').append($(this).clone(ture).css("color","blue")); }) </script> </body> </html>
你引用的 jquery库呢?
加上jquery库,比如<script src="http://libs.baidu.com/jquery/1.9.1/jquery.js"></script>
ture写错了