<!doctype html> <html ng-app> <head> <script src="./jquery.js"></script> </head> <body> <div id="template">hello</div> <script type="text/javascript"> $("#template").click(function(){alert("hello id="+$(this).attr("id"))}) var templateClone = $("#template").clone(true); templateClone.attr("id", templateClone.attr("id")+"_"+1); templateClone.appendTo("body"); </script> </body> </html>
原文:http://www.cnblogs.com/lightsong/p/6230393.html