Last active
August 11, 2017 13:58
-
-
Save anacampesan/b3e70a21d58d7d48b04891fa5a4360f4 to your computer and use it in GitHub Desktop.
Builtin hostname feature in JS
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
$(document).ready(function() { | |
$linkField = $('[name="form-link"]'); | |
$sourceField = $('[name="form-source"]'); | |
$linkField.keypress(function() { | |
$tempA = document.createElement('a'); | |
$tempA.href = $linkField.val(); | |
$sourceField.val($tempA.hostname); | |
$tempA.remove(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment