<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd> <Html xmlns = "http://www.w3.org/1999/xhtml"> <Head> <Title> copy a node </title> <Style type = "text/css"> # Main { Width: 300px; Margin: 200px auto; Background-color: gold; Padding: 10px; } </Style> <Script src = "js/jquery-1.5.1.min.js" type = "text/javascript"> </script> <Script type = "text/javascript"> $ (Function (){ Var $ text = $ ("# txt1 "); $ Text. click (function () {alert ('I am a text box click event ');}); $ ("# Btn1"). click (function (){ $ ("# Btn1"). after ($ text. clone (); // light clone (do not copy the event) }); $ ("# Btn2"). click (function (){ $ ("# Btn2"). after ($ text. clone (true); // deep clone (copy event) }); }); </Script> </Head> <Body> <Div id = "main"> <Input type = "text" value = "I'm a text box" id = "txt1"/> <Input type = "button" id = "btn1" value = "do not copy events)"/> <Input type = "button" id = "btn2" value = "perform deep clone (copy event)"/> </Div> </Body> </Html> |