Skip to content

Instantly share code, notes, and snippets.

@ziadoz
Created April 23, 2013 19:25
Show Gist options
  • Save ziadoz/5446601 to your computer and use it in GitHub Desktop.
Save ziadoz/5446601 to your computer and use it in GitHub Desktop.
jQuery Extends
$.fn.extend({
// ---- HTML Comments ---- //
comments: function() {
return $(this).contents()
.filter(function() {
return this.nodeType == 8;
});
},
// ---- Outer HTML ---- //
outerHtml: function() {
return $(this).clone().wrap('<div>').parent().html();
}
});
$.extend({
// ---- Quick URL Parsing ---- //
parseUrl: function(url) {
var parser = document.createElement('a');
parser.href = url;
return parser;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment