Skip to content

Commit

Permalink
Addeed .replaceWith()
Browse files Browse the repository at this point in the history
  • Loading branch information
zipang authored and statianzo committed Nov 1, 2012
1 parent 54165a8 commit 2bf9658
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/jquip.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,22 @@ window['$'] = window['jquip'] = (function(){
}
return this;
};
p['replaceWith'] = function(val){
if (isF(val)) {
return this['each'](function(i) {
var self = $(this), old = self.html();
self.replaceWith( val.call(this, i, old) );
});
} else if (isS(val)) {
val = $(val).detach();
}
return this['each'](function() {
var next = this.nextSibling,
parent = this.parentNode;
parent.removeChild(this);
(next ? $(next).before(val) : $(parent).append(val));
});
};
p['hide'] = function(){
return this['each'](function(){
cache(this, "display", this.style.display);
Expand Down

0 comments on commit 2bf9658

Please sign in to comment.