Search code examples
jqueryclone

How can I operate on an DOM element cloned with jQuery?


I have a form that I'm trying to duplicate using jQuery. I'm using the clone() method, which returns the cloned object (DOM element). I need to then select elements of the cloned form and manipulate them. Is this possible? If so, how?
I've tried stuff like:

var clonedForm = $("#myForm").clone();
clonedForm.$(".inputField").val();

But (unsurprisingly) the second line doesn't work. Any help would be appreciated, thanks.


Solution

  • I think

    $(clonedForm).find('.inputField').val()