Skip to content

Instantly share code, notes, and snippets.

@cryks
Created November 25, 2010 08:22
Show Gist options
  • Save cryks/715075 to your computer and use it in GitHub Desktop.
Save cryks/715075 to your computer and use it in GitHub Desktop.
$.fn.extend({
sideEffect: function(func) {
func.apply(this);
return this;
}
});
$('<div />')
.append('<img src="hoge.png" />')
.append($('<span />')
.text('fuga')
)
.sideEffect(function() {
var self = this;
$.each(['foo', 'bar', 'hoge', 'fuga', 'piyo'], function() {
self.append($('<span />').text(this));
}
})
.appendTo($('#something'))
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment