Skip to content

Instantly share code, notes, and snippets.

@kadavre
Created June 18, 2017 15:23
Show Gist options
  • Save kadavre/e5782eacb00f053fa4cd253b91d33074 to your computer and use it in GitHub Desktop.
Save kadavre/e5782eacb00f053fa4cd253b91d33074 to your computer and use it in GitHub Desktop.
// You want to parse this address into parts:
var url = 'http://tutorialzine.com/books/jquery-trickshots?trick=12#comments';
// The trick; create a new link with the url as its href:
var a = $('<a>',{ href: url });
console.log('Host name: ' + a.prop('hostname'));
console.log('Path: ' + a.prop('pathname'));
console.log('Query: ' + a.prop('search'));
console.log('Protocol: ' + a.prop('protocol'));
console.log('Hash: ' + a.prop('hash'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment