clone to copy form field values

clone to copy form field values


This code snippet, when added to the clone() method copies form field
values. Tested with IE 7 and FF 2 on Windows.
        // Copy .value and .checked attributes of form fields
        var dstFormElements = ret.find("*").andSelf().filter(":input");
        if (dstFormElements.length > 0)
        {
            var srcFormElements = this.find("*").andSelf().filter(":input");
            dstFormElements.each(function(i)
            {
                $ektron(this).val( srcFormElements.eq(i).val() );
                if ("checkbox" == this.type || "radio" == this.type)
                {
                    this.checked = srcFormElements.get(i).checked;
                }
            });
        }
Please consider adding it to the clone method in the next release of
jQuery.