jQuery method chaining, returned object: something I don't get
Hi, there's something I can't understand. If I do:
elem1 = $('.someclass');
elemx = elem1.wrap(document.createElement('div'));
elemx is... elem1?
Why does jQuery return elem1 and not the created element ? Returning the created element does much more sense to me since:
a) I already got a reference to elem1 if I need to do further manipulation.
b) I got a references to the 'div' element I've just added.
The way jQuery does it, I'll never get a references to the element I've added.
Can anybody clarify this for me? Is it a 'jquery way' to work this?
Thanks in advance. Santiago.