Skip to content

Instantly share code, notes, and snippets.

@smagch
Created October 16, 2019 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smagch/91fc59a3d02182caf208f5581fe9f273 to your computer and use it in GitHub Desktop.
Save smagch/91fc59a3d02182caf208f5581fe9f273 to your computer and use it in GitHub Desktop.
iOS focus test
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>iOS focus Test</title>
<style>
.modal {
transition: opacity 0.3s;
}
.modal.hidden {
visibility: hidden;
opacity: 0;
}
.button {
cursor: pointer;
border: 1px solid gray;
border-radius: tomato;
}
</style>
</head>
<body>
<div class="modal hidden">
<input type='text' />
</div>
<button>button</button>
<script>
const input = document.querySelector('input');
const button = document.querySelector('button');
const modal = document.querySelector('.modal');
button.addEventListener('click', () => {
modal.classList.remove('hidden');
input.focus();
});
input.addEventListener('blur', () => {
modal.classList.add('hidden');
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment