Let’s say I have this jQuery extension method:
$.fn.foobar = function() {
var clone = this.parent().clone();
};
After I’ve gotten clone, how can I find the cloned child element that is the same as this?
Will this work?
$.fn.foobar = function() {
var clone = this.parent().clone();
var cloneOfThis = clone.find(this);
};
Or this?
$.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;
}
});
};
You could try giving it some unique class that could be used to refer back to the proper element.