Difference between clone() and clone(true)

Posted by Prabhukiran345 under jQuery category on | Points: 40 | Views : 581
Clone( ) will not copy any event handlers attached to the cloned object. but clone(true) will copy event handlers attached too.

Example:Consider html code:
<p>, how are you?</p>

Now consider Script:
$('b').click(function () {
alert('Handler for .click() called.');

This indicates that if we click on Hello, then the alert have to be fired.

Now clone() Hello and add to paragraph:

Now if we click on the Hello added to Paragraph,it will not show any Alert message.

Now use clone(true)

This will fire alert message even in Hello added to Paragraph.

Comments or Responses

Login to post response