Skip to content

Instantly share code, notes, and snippets.

@opencoca
Last active February 18, 2025 23:44
Show Gist options
  • Save opencoca/feedb0e00c7782194ac314db189ac420 to your computer and use it in GitHub Desktop.
Save opencoca/feedb0e00c7782194ac314db189ac420 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Emoji Selector</title>
<style>
.container {
display: flex;
gap: 10px;
}
button {
padding: 10px 20px;
font-size: 20px;
cursor: pointer;
}
#emojiBtn {
font-size: 24px;
width: 60px;
}
#textField {
width: 300px;
height: 100px;
padding: 10px;
font-size: 16px
}
</style>
</head>
<body>
<div class="container">
<button id="decrementBtn">-</button>
<button id="emojiBtn"></button>
<button id="incrementBtn">+</button>
</div>
<textarea id="textField" placeholder="Click emoji to add it here..."></textarea>
<script>
let currentCodePoint = 0x1F600:
const emojiBtn = document.getElementById('emojiBtn');
const textField = document.getElementById('textField');
function updateEmojiDisplay() {
emojiBtn.textContent = String.fromCodePoint(currentCodePoint);
}
document.getElementById('incrementBtn').addEventListener('click', () => {
currentCodePoint++;
updateEmojiDisplay();
});
document.getElementById('decrementBtn').addEventListener('click', () => {
currentCodePoint--;
updateEmojiDisplay();
});
// Emoji selection
emojiBtn.addEventListener('click', () => {
textField.value += String.fromCodePoint(currentCodePoint);
});
updateEmojiDisplay();
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment