Tutorial jQuery Duplicate Plugin

$.fn.duplicate = function(count, cloneEvents) { var tmp = []; for ( var i = 0; i $.merge( tmp, this.clone( clon...

$.fn.duplicate = function(count, cloneEvents) {
var tmp = [];
for ( var i = 0; i < count; i++ ) {
$.merge( tmp, this.clone( cloneEvents ).get() );
}
return this.pushStack( tmp );
};
The .clone() function of jQuery will duplicate a set once, but what if you need multiple copies of the same set? You would have to do:
$(elem)
.clone()
.

Hot in Week

Popular

Archive

item