Skip to content

Instantly share code, notes, and snippets.

@anacampesan
Last active August 11, 2017 13:58
Show Gist options
  • Save anacampesan/b3e70a21d58d7d48b04891fa5a4360f4 to your computer and use it in GitHub Desktop.
Save anacampesan/b3e70a21d58d7d48b04891fa5a4360f4 to your computer and use it in GitHub Desktop.
Builtin hostname feature in JS
$(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