Oh I finally got it! I'm such an amateur in jQuery. I know what you're saying, it's just that it never crossed my mind that the clone function affects the original object instead of returning a new one. Thanks for your time and sorry for the confusion.
 
thanks

 
On 9/30/06, Renato Formato <[EMAIL PROTECTED]> wrote:
Raziel Alvarez ha scritto:
> Ok, I won't argue anymore about the clone(), though I think it's not the
> behaviour that anyone expects (think on the cloneNode() function) and
> the documentation then is incorrect or very very confusing: /"Create
> cloned copies of all matched DOM Elements. This does not create a cloned
> copy of this particular jQuery object, instead it creates duplicate
> copies of all DOM Elements." /To me this is completely the opposite that
> you are saying.
>
> Independently of how the clone() should work, then please explain why I
> get two completely different behaviours with this two snippets of code:
>
> ===========================
> <div class="templateDiv">TEMPLATE</div>
> ===========================
>
> var templateDiv = $('.templateDiv');
> var templateDivCopy = templateDiv.clone().get(0);  // templateDivCopy is
> a reference of the original templateDiv
>
> and
>
> var templateDivCopy = $('.templateDiv').clone().get(0);
>
>
> with the first one, if I do templateDivCopy.innedHTML = "ANY TEXT", then
> this sets the innerHTML of BOTH elements; but in the second case, if I
> do the same, only the copy is affected!
>

I don't see your behavior.
I've used the code of the first case and appended the cloned element to
body just to see it on the screen.

Here is a live demo:
http://www.fbtools.com/jquery_test/

Renato


_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to