Created
June 18, 2017 15:23
-
-
Save kadavre/e5782eacb00f053fa4cd253b91d33074 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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