Let's say I have this jQuery extension method:
$.fn.foobar = function() {
var clone = this.parent().clone();
};
After I got it clone, how can I find a cloned child that matches this?
Will this work?
$.fn.foobar = function() {
var clone = this.parent().clone();
var cloneOfThis = clone.find(this);
};
Or that?
$.fn.foobar = function() {
var clone = this.parent().clone();
var self = this;
var cloneOfThis;
clone.children().each(function() {
var $this = $(this);
if ($this === self) {
cloneOfThis = $this;
}
});
};
source
share