Skip to content

Instantly share code, notes, and snippets.

@jorik041
Forked from ziadoz/extends.js
Created June 23, 2013 05:51
Show Gist options
  • Save jorik041/5843955 to your computer and use it in GitHub Desktop.
Save jorik041/5843955 to your computer and use it in GitHub Desktop.
$.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