I am looking to add functionality to a jQuery method.
I have the code
$('li.s').appendTo('#target');
There are multiple elements which match li.s
, and I can see it's grabbed correctly using Firebug.
The append
method works fine without my wrapper. However, with my wrapper (which shouldn't change anything about the function):
var oldAppend = $.fn.append;
$.fn.append = function(expr) {
return oldAppend.call(this, expr);
};
The correct jQuery object is returned, but only the first li.s
is appended to #target
, instead of all of them. Why is this? Where am I losing my other elements in the call to oldAppend
?