Skip to content

Instantly share code, notes, and snippets.

@kobitoDevelopment
Last active November 22, 2025 03:46
Show Gist options
  • Select an option

  • Save kobitoDevelopment/926290d09e3442317f5d39006a0609af to your computer and use it in GitHub Desktop.

Select an option

Save kobitoDevelopment/926290d09e3442317f5d39006a0609af to your computer and use it in GitHub Desktop.
<select id="actionSelect">
<option value="open">window.openを実行</option>
<option value="copy">クリップボードにコピー</option>
</select>
document.addEventListener('DOMContentLoaded', () => {
const select = document.getElementById('actionSelect');
select.addEventListener('change', (e) => {
if (e.target.value === 'open') {
window.open('https://example.com', '_blank');
} else if (e.target.value === 'copy') {
navigator.clipboard.writeText('テストテキスト');
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment